Hi @jasongeslois
You can try this:
library(tidyverse)
mydf <- data.frame(
"percentone" = as.numeric(c(65, 75, 102)),
"percenttwo" = as.numeric(c(103, 104, 89))
)
percent <- "percentone"
mydf %>%
mutate(x = eval(parse(text = percent)) > 100 )
#> percentone percenttwo x
#> 1 65 103 FALSE
#> 2 75 104 FALSE
#> 3 102 89 TRUE
You can also consider a function, or add test columns for all relevant columns in one go, like this for instance:
mydf %>%
mutate(across(starts_with("percent"), ~. > 100, .names = "{.col}_test"))
#> percentone percenttwo percentone_test percenttwo_test
#> 1 65 103 FALSE TRUE
#> 2 75 104 FALSE TRUE
#> 3 102 89 TRUE FALSE
Hope it helps.