# defining the columns of the data frame
data_frame <- data.frame(col1=c(rep("A", 10) ,
rep("B", 12) ,
rep("C", 18)),
col2=c( sample(2:5, 10 ,
replace=T) ,
sample(4:10, 12 ,
replace=T),
sample(1:7, 18 ,
replace=T))
df_col1 <- list(data_frame$col1)
# computing the mean data frame
data_mod <- aggregate(data_frame$col2,
df_col1,
mean)
# plotting the boxplot
boxplot(data_frame$col2 ~ data_frame$col1)
# calculating rows of data_mod
row <- nrow(data_mod)
# marking the points of the box plot
points(x = 1:row,
y = data_mod$x,
col = "red",
pch = 14
)
# adding text to the plot
text(x = 1:row,
y = data_mod$x - 0.15,
labels = paste("Mean - ", round(data_mod$x,2)),
col = "dark green")