- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 a line chart with mean and standard deviation using ggplot2 in R?
Sometimes we have mean and standard deviation given for groups or factors, these are generally obtained from previous research studies and is referred to as the secondary data. In this case. the line chart with mean and standard deviation using ggplot2 can be created by defining the minimum and maximum inside geom_error function of ggplot2 package, where the difference between mean and standard deviation defines the standard deviation if the minimum is set as mean minus one standard deviation and the maximum is set as mean plus one standard deviation.
Consider the below data frame −
Group<−c("G1","G2","G3","G4") Mean<−c(25,27,23,26) SD<−c(3.24,2.25,3.6,4.1) df<−data.frame(Group,Mean,SD) df
Group Mean SD 1 G1 25 3.24 2 G2 27 2.25 3 G3 23 3.60 4 G4 26 4.10
Loading ggplot2 package and creating the plot with mean and standard deviation −
- How to create boxplot using mean and standard deviation in R?
- How to create a line chart using ggplot2 with a vertical line in R?
- How to create a line chart using ggplot2 with larger width in R?
- How to create line chart using ggplot2 in R with 3-sigma limits?
- Create line chart for mean covered with minimum and maximum in R.
- How to create a line chart using ggplot2 that touches the edge in R?
- How to create bar chart using ggplot2 with chart sub-title in R?
- How to create line chart for categories with grey color palette 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 create a point chart with empty points using ggplot2 in R?
- How to create a line chart for a subset of a data frame using ggplot2 in R?
- PyTorch – How to normalize an image with mean and standard deviation?
- How to create the bar chart with ggplot2 using color brewer in R?
- How to create grouped line chart using ggplotly in R?