I have an R script which computes several linear models but also ggplots etc. Now I want to run it with changing variables.
Depending on my specifications
df$targetX
should be interpreted as:
df$target_37
and
lm(targetX ~ kelvin, df)
should compute a linear model like I called:
lm(target_37 ~ kelvin, df)
I experimented with formula()
, paste()
, parse()
and eval()
without success.
Is there a way I can specify targetX to achieve this and without having to touch the analysis script?
targetX <- smartCommandIdontKnow("target_37")