I'm trying to add solutions of a formula to a data frame using dplyr. With the function mutate() I want to create a column called cutoff. The rows in the column cutoff should contain the solution of the formula stored in a2.
Here is my code:
library(dplyr)
a1 <- "AVG(C1) * .290"
a2 <- gsub("AVG[(]C1[)]","mean",a1)
newiris <- iris %>%
group_by(Species) %>%
summarize(n= n(),mean = mean(Petal.Width),
cv=sd(Petal.Width)/mean(Petal.Width)*100) %>%
mutate(cutoff=a2)
This is want I get in the moment:
This is what I want:
Any help would be appreciated.