Visualization with ggplot2

Jim Duggan · 2024

A key element of any data analysis and modelling process is to have the facility to visualise data, and explore relationships between variables. Within R&s;s tidyverse we are fortunate to have access to a power visualisation library ggplot2. There are three important benefits of using ggplot2: (1) plots can be designed in a layered manner; (2) a wide range of informative plots can be generated to support decision analysis (e.g. including scatterplots, histograms and time series charts), and (3) charts can be developed rapidly, and which supports the process of exploratory data analysis. This chapter starts with a simple scatterplot, and shows how this can be extended to provide information on multiple variables. Statistical transforms are introduced, as they are used to generate plots such as bar charts, box plots and histograms. Features such as themes are introduced, as these allow the analyst to control non-data elements of a plot. The chapter concludes with a mini-case showing how ggplot can be used to visualise and format time series data.

Read the paper · More papers on PaperTik