- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create boxplot using mean and standard deviation in R?
The main statistical parameters that are used to create a boxplot are mean and standard deviation but in general, the boxplot is created with the whole data instead of these values. If we don’t have whole data but mean and standard deviation are available then the boxplot can be created by finding all the limits of a boxplot using mean as a measure of central tendency.
Consider the below data frame:
> df<-data.frame(mean=c(24,25,27,24),sd=c(1.1,2.1,1.5,1.8),Category=as.factor(c("A","B","C","D"))) > df
mean sd Category 1 24 1.1 A 2 25 2.1 B 3 27 1.5 C 4 24 1.8 D
Loading ggplot2 package and creating the boxplot of each category in df:
> library(ggplot2) > ggplot(df,aes(x=Category))+geom_boxplot(aes(lower=mean-sd,upper=mean+sd,middle=mean,ymin=mean-3*sd,ymax=mean+3*sd),stat="identity")
- Related Articles
- How to create a line chart with mean and standard deviation using ggplot2 in R?
- How to find mean and standard deviation from frequency table in R?
- Plot mean and standard deviation in Matplotlib
- How to display mean inside boxplot created by using boxplot function in R?
- PyTorch – How to normalize an image with mean and standard deviation?
- How to compute the mean and standard deviation of a tensor in PyTorch?
- How to create boxplot using ggplot2 without whiskers in R?
- Absolute Deviation and Absolute Mean Deviation using NumPy
- How to create transparent boxplot in R?
- How to find the moving standard deviation in an R matrix?
- Generate random numbers by giving certain mean and standard deviation in Excel
- How to create boxplot for list elements using ggplot2 in R?
- How to create a boxplot using ggplot2 with aes_string in R?
- How to create boxplot using ggplot2 without box border in R?
- How to divide the matrix rows by row standard deviation in R?