As part of a more complicated issue, I am trying to grab a string from a list that matches a variable I want to plot.
# http://www.cookbook-r.com/Graphs/Plotting_distributions_(ggplot2)/
set.seed(1234)
df <- data.frame(cond = factor( rep(c("A","B"), each=200) ),
rating = c(rnorm(200),rnorm(200, mean=.8)))
library(ggplot2)
myList <- list(something=c("rating", "foo1"),
else=c("foo2", "foo3"))
myList[[1]][1] # [1] "rating"
# does not work
ggplot(df, aes(x=myList[[1]][1])) + geom_histogram(binwidth=.5)
# works
ggplot(df, aes(x=rating)) + geom_histogram(binwidth=.5)
I want to get rating
from my list rather than type it directly. Any ideas how to achieve this?