I am using Iris dataset in R.
I have the following code
for (i in colnames(iris[-5])) { plot(iris$Species, iris[[i]], xlab = 'Species', ylab = `i`) } This prints out 4 boxplot. I want to do the same in ggplot with the following code
for (i in colnames(iris[-5])) { print(iris %>% ggplot(aes(x = Species)) + geom_col(aes(y = i))) } When I do this in ggplot, the boxplots look messed up. Is it just my R or am I missing something?
geom_boxplot(aes(y = !!sym(i))))will give you what you want, after correcting the obvious typo in your code. By the way "look messed up" isn't terribly helpful. Please be more specific.