I have a sample data.table data as below:
VarName Formulae
1: A 1+1
2: B A+3
3: C B*10
4: D A+C
5: E D/2
I want to convert the Formulae column into formulas, so that the output can become like:
VarName Result
1: A 2
2: B 5
3: C 50
4: D 52
5: E 26
Basically the VarName column is the variable name and the Formulae column is the corresponding formula.
A = 1+1
B = A+3
C = B*10
D = A+C
E = D/2
I have tried using the eval and parse functions like data$VarName = eval(parse(text = "data$Formulae")), however I could not get the desired output.