Add a Statistical Layer on Line Chart in ggplot2

Premium

R has become very popular not just because of its data visualization capabilities but also its ability to combine data visualizations with statistical information. The statistics layer helps us represent statistical information about the data, such as mean and variance, to help in understanding the data.

We earlier learned about geoms which stand for "geometric objects." These are the core elements that you see on the plot, and includes objects such as points, lines, areas, and curves. Stats stand for "statistical transformations." These help us summarize the data in different ways such as counting observations, creating a linear regression line that best fits the data, or adding a confidence interval to the regression line.

Continue Reading
Premium Content

This tutorial is a part of the course Data Visualization with R. This is a premium course. The purchase options for the course are provided below. With this course, you get access to complete course content, source code, practical exercises, and all resources that are a part of the course.

Lifetime Premium Membership
$250
$179

Get unlimited access to all courses and premium content

Join Premium
Individual Course
$7

Purchase this course individually

Purchase CourseView Course Details
What's Included:
Complete access to course content and updates
All downloadable resources
Interactive course quizzes
Practice exercises and sample code
Ad-free learning experience