Reason 7 Powerful data visualization

Perhaps the most popular package for data visualization in R is {ggplot2}. It comes with the {tidyverse} package, but there are many other packages that extend the functionality of {ggplot2}, such as {ggforce} or {gganimate}.

These packages share a unifying design principle, the Grammar of Graphics (hence the “gg”). At its core, the Grammar of Graphics is about mapping attributes of your data (such as the magnitude of a number or the category that an observation belongs to) to aesthetics of geometric objects (such as position and size of a point or the height and color of a bar), potentially after applying statistical transformations like counting or averaging observations. This foundation turns out to be extremely versatile and allows

You can see examples of what is possible with {ggplot2} in the submissions for Tidy Tuesday – a weekly exercise for practicing data visualisation. Some people even use {ggplot2} to make generative Art!

Mastering {ggplot2} can take a while. However, there are some websites that provide example code for different types of charts. The R graph gallery is particularly comprehensive. There are also packages like {esquisse} that provide you with an intuitive graphical user interface for using {ggplot2}.

The {ggplot2} package itself is mainly limited to static graphs. However, packages like {plotly}, and {shiny} allow you to make interactive visualizations and dashboards with relative ease. Integration with JavaScript (e.g., D3.js) - the sky is the limit!

See ggplot2 – Elegant graphics for data analysis for a deep dive into {ggplot2}

7.1 The fastest way to make a plot

In a short intro like this, there is not enough time to dive deeply into {ggplot2}.

# ...

7.2 Build a plot with the grammar of graphics

# ...

7.3 Make an interactive plot

# ...