I want to create multiple boxplots using for loop but having problems achieving the desired output.
Here as an example of what I have done:
library(ggplot2)
library(magrittr)
for(i in colnames(iris[1:4])) {
print(iris %>% ggplot(aes(x = Species, y = i)) + geom_boxplot())
}
It is performing a loop but the output is just flat boxplots. Am I incorrect in assuming that where I put y = i, that the i value takes on the name of the column name through the iteration?