I'm trying to convert strings from a column into formulas and output the result based on values I specify. For example:
Compo <- c("FE56", "FE58", "FE61", "YI68", "FE11")
Formula <- c("( FE13 / 0.06 ) * CE68",
"( ( CE01 + CE02 + CE03 ) / 100 ) * ( 393682 / 10000 )",
"FE12 / 0.06",
"CE68",
"FQ11")
table <- data.frame(Compo, Formula)
FE13 <- 13
CE68 <- 20
CE01 <- 5
CE02 <- 15
CE03 <- 5.067
FE12 <- 35
FQ11 <-37
table$resultado <- parse(text = tabela$Formula)
table$results <- eval(tabela$resultado)
But the column results
only returns the value from the last formula, when it supposed to return the result from each formula.