Is there a way to call a variable from a list using ggplot2? I am trying to create an interactive/all purpose script for a colleague.
This is how I usually plot something:
ggplot(df, aes(x = variable1)) + geom_histogram()
But for this script, I want something like:
plot_this_variable <- "variable1"
ggplot(df, aes(x = plot_this_variable)) + geom_histogram()
Is this possible? If so, how?
Edit:
Solution, use aes_string() instead of aes().