MA206 Code Movies

A companion for the MA206 Tidyverse Tutorial


“MA 206 Code Movies” is a companion guide to the MA206 tidyverse tutorial. It dissects the Tutorial’s code pipelines and presents them step-by-step.

For discussion of the example data and functions, refer back to the MA206 Tidyverse Tutorial guide.


1. Using Tidyverse to Explore the Data

In this example:

read_csv() read in comma separated values file

select() choose columns

filter() keep or drop rows

mutate() create new variable (column)

summarise() summarize data (sometimes used with group_by())

First, we use the read_csv() command to bring our data into RStudio, then we look at what the filter(), mutate(), and select() commands can do in a pipeline:

View code-movie in a new tab or below:

We can also use the summarize() command to create new variables for later use. Here, we use it to identify the mean earnings of our sample population:

View code-movie in a new tab or below:



2. Using ggplot2 to Explore the Data


In this example:

ggplot(), aes(), labs(), group_by(), facet_wrap(), geom_histogram(), geom_point(), geom_smooth(), geom_line(), geom_boxplot()

Ex. 2.1: Histogram

View code-movie in a new tab or below:

Ex. 2.2: Scatterplot

View code-movie in a new tab or below:

Ex. 2.3: Line Plot

View code-movie in a new tab or below:


3. Using ggplot2 functions for data visualization

In this example:

labs(), scale_\*_\*(), theme_X()

Labels and scales

View code-movie in a new tab or below:

Themes

View code-movie in a new tab or below:



4. Additional ggplot2 Geometric Objects

In this example:

geom_col(), geom_bar(), geom_dotplot(), group_by(), factor(), c()

These demos are not included in the Tidyverse Tutorial, but build on the extra ggplot2 uses mentioned at the end of the section. Additionally, the Dot Plot example utilizes 8gapminder* data different from that used in all previous examples.

Ex. 4.1: Column Chart

View code-movie in a new tab or below:

Ex. 4.2: Bar Plot

View code-movie in a new tab or below:

Ex. 4.3: Dot Plot

View code-movie in a new tab or below:

END