#activate the package library(ggplot2) #load the dataframe ID <- 1:400 values <- c(rnorm(200, mean=50, sd=22), rnorm(200, mean=20, sd=10)) class <- c(rep("first", 200), rep("second",200)) my.dataframe <- data.frame(ID, values, class) #boxplot with 2 categories ggplot(my.dataframe, aes(class, values)) + geom_boxplot() #boxplot with 2 categories, 2 colors and the legend ggplot(my.dataframe, aes(class, values, fill=class)) + geom_boxplot()