I am building a loop to print a series of plots to separate files in R. Everything works except that when I try to pass a variable to aes in ggplot, the geom_histogram thinks the value is now discrete.
So this works:
epdSimpleName <- c("API", "TI", "CE")
for (epdName in epdSimpleName) {
plot <- ggplot(simpledf, aes(x=API))
plot <- plot + geom_histogram(binwidth=5)
print(plot)
}
but this does not:
epdSimpleName <- c("API", "TI", "CE")
for (epdName in epdSimpleName) {
plot <- ggplot(simpledf, aes(x=epdName))
plot <- plot + geom_histogram(binwidth=5)
print(plot)
}
because R thinks that API, TI, etc is then discrete I guess?
Error: StatBin requires a continuous x variable: the x variable is discrete. Perhaps you want stat="count"?
Thanks for any help/guidance!

