Easy Steps for Data Visualizations in R using ggplot2

Learn data visualization in R by knowing the grammar of graphics, a set of tools for constructing statistical plots

Renu Khandelwal
8 min readNov 25, 2021

You have explored the data by looking at the raw data, running the summary statistics; you have questions about your data and want to answer those questions by understanding the relationship between different variables in the dataset. The best way would be to visualize the data using various graphs.

Learn what type of graph to use for what kind of data and how to visualize the data using ggplot2.

What is ggplot2?

ggplot2 is an R package for producing statistical graphs.

ggplot2 uses an underlying grammar of graphics just like the grammar for any language. A language is composed of elements like nouns, verbs, pronouns, objects, etc. similarly, ggplot2 manages graphs by combining independent components.

gg in ggplot2 is the grammar of graphics

What is the grammar of graphics in ggplot2?

A statistical graph is a mapping of data variables to aesthetic attributes of geometric objects.

ggplot2 has five ingredients

  • data: the dataset containing the variables of interest.
  • mapping : mapping the data to the aesthetic features of visualization, like the X and the Y-axis, color, shape, and…

--

--

Renu Khandelwal

A Technology Enthusiast who constantly seeks out new challenges by exploring cutting-edge technologies to make the world a better place!