

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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.
Example
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
Output
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:
Example
> 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")
Output:
- Related Questions & Answers
- 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
- Absolute Deviation and Absolute Mean Deviation using NumPy
- 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 display mean inside boxplot created by using boxplot function in R?
- Variance and Standard Deviation
- How to find the moving standard deviation in an R matrix?
- How to create transparent boxplot in R?
- How to create boxplot using ggplot2 without whiskers in R?
- How to find the standard error of mean in R?
- How to divide the matrix rows by row standard deviation in R?
- How to find the moving standard deviation in an R data frame?
- How to create boxplot for list elements using ggplot2 in R?
Advertisements