Parse and Evaluate Column of String Expressions in R?
问题 How can I parse and evaluate a column of string expressions in R as part of a pipeline? In the example below, I produce my desired column, evaluated . But I know this isn't the right approach. I tried taking a tidyverse approach. But I'm just very confused. library(tidyverse) df <- tibble(name = LETTERS[1:3], to_evaluate = c("1-1+1", "iter+iter", "4*iter-1"), evaluated = NA) iter = 1 for (i in 1:nrow(df)) { df[i,"evaluated"] <- eval(parse(text=df$to_evaluate[[i]])) } print(df) # # A tibble: 3