
Let’s begin the course with the content coverage.
Before we dive deep into the concepts and practice exercises, let us first install R and RStudio to get started.
Let us begin with the first lesson and understand what we are going to cover in our learning journey.
ggplot2 is a visualization package in R. It was developed in 2005 and it uses the concept of the ‘Grammar of Graphics’ to build a plot in layers and scales. This is the syntax used for the different components (aesthetics) of a geometric object. It also involves the grammatical rules for creating a visualization. Let us learn more about it with the following topics:
Introduction to ggplot2
Loading and Exploring a Dataset Using R Functions
The Main Concepts of ggplot2
Types of Variables
Exploring Datasets
The ggplot2 function qplot is similar to the basic plot () function from the R package. It can be used to build and combine a range of useful graphs; however, it does not have the same flexibility as the ggplot() function. Let us now create our first plot with qplot and R.
The geometric objects in ggplot2 are visual structures that are used to visualize data. They can be lines, bars, points, and so on. Geometric objects are constructed from datasets. Before we construct some geometric objects, let's examine some datasets to understand the different kinds of variables. Here are the topics that we will cover now:
Geometric Objects
Analyzing Different Datasets
Histograms
Examples of Unimodal and Bimodal Distribution
Creating a Histogram Using qplot and ggplot
Bar charts are more general than histograms, and they can represent both discrete and continuous data. They can even be used to represent categorical variables. A bar chart uses a horizontal or vertical rectangular bar that levels off at an appropriate level. A bar chart can be used to represent various quantities, such as frequency counts and percentages. Let us learn this with the following exercises:
Create Bar Charts
Create a One-Dimensional Bar Chart
Create a Two-dimensional Bar Chart
A boxPlot is a standard way of displaying the distribution of data based on a five-number summary: minimum, first quartile, median, third quartile, and maximum. Boxplots can represent how a continuous variable is distributed for different categories; one of the axes will be a categorical variable, while the other will be a continuous variable. Let us begin with the following exercises:
Analyze and Create BoxPlots
Create a BoxPlot for a Given Dataset
Create Scatter Plots
A line chart shows the relationship between two variables; it is similar to a scatter plot, but the points are connected by line segments. In this section, we will learn more about Line Charts in detail.
The Grammar of Graphics is the language used to describe various components of a graphic that represents data in visualization. Let us understand the following concepts:
The Grammar of Graphics
Rebinning
Analysis of Histograms
Using the Grammar of Graphics to change Boxplot Defaults
Summarize your learning from this lesson.
Let us begin with the second lesson and understand what we are going to cover in our learning journey.
The Grammar of Graphics is the language used to describe the various components of a graphic that represent data in a visualization. In this video, you will learn more about the Grammar of Graphics and will use it to make plots. Let us dive deep and learn about:
Layers
Use More Layers to Customize a Histogram
Scales map values in a data space to values in an aesthetic space, whether the value is a color, shape, or size. Scales are used to change legends or axes, providing inverse mapping and enabling us to understand the data from the graphic itself. In the previous video, when we plotted the histogram, ggplot applied a default scale, in order to describe the x- and y-axes. Let us understand the following concepts:
Scales
Use Scales to Analyze a Dataset
Types of Coordinates
Understand Polar Coordinates
In data visualization, we sometimes have the need to compare different groups, looking at data alongside each other. One method for doing this is creating a subplot for each group. These kinds of plots are known as Trellis displays. In ggplot2, they're called facets. Facets divide the data by some discrete or categorical variable and display the same type of graph for each data subset. In this section, we will learn more about Facets in detail.
Aside from faceting, we can also produce a color differentiated plot. It can be advantageous to use a color differentiated plot when the shapes are very similar and there is some overlap. To see small differences, it is useful to use colors. Let us learn this with the following exercises:
Use Different Colors to Group Points by a Variable
Explore Themes and Changing the Appearance of Graphs
Use a Theme to Customize a Plot
Let us now set individual themes globally.
We can use geoms and statistical summaries to create a summarized plot. Let us understand the following concepts:
Geoms and Statistical Summaries
Use Grouping to Create a Summarized Plot
Summarize your learning from this lesson.
Let us begin with the third lesson and understand what we are going to cover in our learning journey.
Two of the most common advanced plotting techniques are scatter plots and bubble charts. Scatter plots show the relationship between two variables. A bubble chart can include a third variable. Let us learn this with the following exercises:
Create a Bubble Chart
Use Density Plots
Superimpose Plots
A time series is a sequence of data points that are recorded at specific times. Time series are often used in the finance, trading, and housing industries. They are also used by scientists for predicting earthquakes, weather, and so on. In this section, we will learn more about it in detail.
Let us now draw and display information with maps.
Statistical summaries are useful for summarizing a group of points. You may want to see different quantities (such as the minimum, maximum, mean, median, or quantiles) for a time series plot or a line chart that includes multiple y values for a given x value. We will use the financial data from Facebook and the statistical summary tool to better understand the trends. Let us understand the following concepts:
Time Series Plot with Mean, Median, and Quantiles
Trends, Correlations, and Scatter Plots
Scatter Plot and Fitting a Linear Regression Model
Correlation matrixes show the correlation coefficients between a relatively large numbers of continuous variables. However, while R offers a simple way to create such matrixes through the cor function, it does not offer a plotting method for the matrixes created by that function. In this section, we will learn more about correlation plot in detail.
Summarize your learning from this lesson.
Applied Data Visualization with R and ggplot2 introduces you to the world of data visualization by taking you through the basic features of ggplot2. To start with, you'll learn how to set up the R environment, followed by getting insights into the grammar of graphics and geometric objects before you explore the plotting techniques.
You'll discover what layers, scales, coordinates, and themes are, and study how you can use them to transform your data into aesthetical graphs. Once you've grasped the basics, you'll move on to studying simple plots such as histograms and advanced plots such as superimposing and density plots. You'll also get to grips with plotting trends, correlations, and statistical summaries.
By the end of this course, you'll have created data visualizations that will impress your clients.
About the Author
Chris DallaVilla is the founder and CEO of VALID., an independent marketing consulting practice specializing in providing data-driven solutions that help chief marketing officers and their teams strengthen their planning and execution, and drive results. Chris has expertise in digital and social media marketing, as well as certifications in Agile, Google AdWords, and Google Analytics. He studied computer science at Harvard University, design technology at Massachusetts College of Art and Design, and advertising and marketing communications at the Questrom School of Business at Boston University.
Tania Moulik has a PhD in particle physics. She has worked at CERN, the European Organization for Nuclear Research, and on the Tevatron at Fermi National Accelerator Laboratory in IL, USA. She has years of programming experience in C++, Python, and R. She has also worked in the feld of big data and has worked with technologies such as grid computing. She has a passion for data analysis and would like to share her passion with others who would like to delve into the world of data analytics. She especially likes R and ggplot2 as a powerful analytics package.