Sorry, but I'm struggling with a quite simple problem: A formula/an expression like 1.28*10^2 is saved as a character in a data frame. Now I want to convert this string into a numeric value - this should result in "128", but it does not.
library(dplyr)
mydata <- data.frame(
formula = c("5.89*10^3", "1.28*10^2", "4.11*10^5")
)
mydata <- mydata %>%
dplyr::mutate(eval = eval(parse(text = formula)))
The variable "eval" should contain the values 5890, 128 and 411000 in the end.
Can anyone help where my mistake is? Thank you!