0

I work on a script which I want to apply to multiple outcome variables which I try to define in the beginning of the script and then be able to modify it easily

at the beginning I have something like

outcome_variable <<- "parameter244"

In most components of my script it works if I simply use outcome_variable from then on instead of parameter244 but in the following function it doesn't work – I think I have to escape the variable somehow...

index.training <- createDataPartition(analyze_data.norm$outcome_variable, p = 0.8, list = FALSE) %>% as.vector()

it works with

index.training <- createDataPartition(analyze_data.norm$parameter244, p = 0.8, list = FALSE) %>% as.vector()
Str1atum
  • 1
  • 2
  • Use `analyze_data.norm[[outcome_variable]]` – Ronak Shah Aug 26 '21 at 10:58
  • Thanks! But how to use the outcome_variable in a option of another function? e.g. ggplot(aes(x = feature, y = value, fill = outcome_variable)) ggplot(aes(x = feature, y = value, fill = get(outcome_variable))) both do not work, the graph title is just "outcome_variable" and not "parameter244" – Str1atum Aug 27 '21 at 07:39

0 Answers0