I want this type of boxplot for several y-variables in my dataset: normal boxplot for all irises with Species as x-value. Since I have multiple y variables to plot, I tried to use lapply like this:
varlist <- c('Sepal.Length', 'Sepal.Width')
plot <- function (varlist) {
require(ggplot2)
ggplot(data = iris, aes(x=Species, y=varlist))+
geom_boxplot()
}
lapply(varlist, FUN = plot)
I got this plot: with only one iris per plot
How can I get normal boxplots using a type of loop (because of several y-values), and where all irises grouped by the x-variable are included in the boxes?