In this post I am going to show how to draw boxplot using R studio with existing data set. For this I am uisng sleep data set.
Boxplots
to include the mean to the boxplot we can use below script.
To view the Hirizental box plot with filling colors, we can use below syntax
Thank You !!!
Boxplots
- are a perfect way to compare distributions of different groups
- allow a good overview: min, max, median,
- quartiles 1 and 3, outliers
- they often come together with ANOVA
- standard tool for scientific publications
sleepboxplot = boxplot(data = sleep, extra ~ group,
main = "Change in sleep duration",
col.main = "red", ylab="change in hrs", xlab="drug")
to include the mean to the boxplot we can use below script.
attach(sleep)
means = by(extra, group, mean)
points(means, col = "red")
horizontalboxplot = boxplot(data = sleep, extra ~ group, ylab="", xlab="", horizontal = T)
To view the Hirizental box plot with filling colors, we can use below syntax
horizontalboxplot = boxplot(data = sleep, extra ~ group, ylab="", xlab="", horizontal = T, col = c("blue", "red") )
Thank You !!!
Boxplot in R
Reviewed by Pubudu Dewagama
on
11:11:00 PM
Rating:
No comments: