I am trying to evaluate expressions inside a mutate() command and I'm getting errors. Here's what my code looks like right now:
depvar <- "foo"
transformedvars[1] <- "mean(bar)"
dataset %>% mutate(paste0("t", depvar) = transformedvars[1])
I want to use mutate() to create a column called tfoo and have it take as values the result of calling up mean(bar), where bar is another column in my data.
The error I am getting is:
Error: unexpected '=' in: "dataset %>% mutate(paste0("t", depvar) ="