You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 01-reading.Rmd
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -425,8 +425,8 @@ so that we can share it with others or use it for another step in the analysis.
425
425
The default arguments for this file are to use a comma (`,`) as the delimiter and include column names. Below we demonstrate creating a new version of the US state-level
426
426
property, income, population and voting data from 2015 and 2016 that does not contain the territory of Puerto Rico, and then writing this to a `.csv` file:
427
427
428
-
```{r}
429
-
state_data <- filter(us_data, state != "PR")
428
+
```
429
+
state_data <- filter(us_data, state != "Puerto Rico")
Copy file name to clipboardExpand all lines: 03-viz.Rmd
+11-9Lines changed: 11 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -112,24 +112,26 @@ options(warn=-1)
112
112
113
113
114
114
### The Mauna Loa CO2 data set
115
-
This data set contains the atmospheric concentration of carbon dioxide (CO2, in parts per million) at the Mauna Loa research station in Hawaii
116
-
from the years 1959-1997. **Question:** Does the concentration of atmospheric CO2 change over time, and are there any interesting patterns to note?
115
+
The [Mauna Loa CO2 data set](https://www.esrl.noaa.gov/gmd/ccgg/trends/data.html), curated by [Dr. Pieter Tans, NOAA/GML](https://www.esrl.noaa.gov/gmd/staff/Pieter.Tans/) and [Dr. Ralph Keeling, Scripps Institution of Oceanography](https://scrippsco2.ucsd.edu/)
116
+
records the atmospheric concentration of carbon dioxide (CO2, in parts per million) at the Mauna Loa research station in Hawaii from 1959 onwards. **Question:** Does the concentration of atmospheric CO2 change over time, and are there any interesting patterns to note?
117
117
```{r 03-data-co2, warning=FALSE, message=FALSE}
118
118
# mauna loa carbon dioxide data
119
-
co2_df <- read_csv("data/maunaloa.csv")
119
+
co2_df <- read_csv("data/mauna_loa.csv") %>%
120
+
filter(ppm > 0, date_decimal < 2000)
120
121
head(co2_df)
121
122
```
122
123
123
124
Since we are investigating a relationship between two variables (CO2 concentration and date), a scatter plot is a good place to start. Scatter plots
124
-
show the data as individual points with `x` (horizonal axis) and `y` (vertical axis) coordinates. Here, we will use the date as the `x` coordinate
125
+
show the data as individual points with `x` (horizonal axis) and `y` (vertical axis) coordinates. Here, we will use the decimal
126
+
date as the `x` coordinate
125
127
and CO2 concentration as the `y` coordinate. When using the `ggplot2` library, we create the plot object with the `ggplot` function; there are
126
128
a few basic aspects of a plot that we need to specify:
127
129
128
130
- the *data*: the name of the dataframe object that we would like to visualize
129
131
- here, we specify the `co2_df` dataframe
130
132
- the *aesthetic mapping*: tells `ggplot` how the columns in the dataframe map to properties of the visualization
131
133
- to create an aesthetic mapping, we use the `aes` function
132
-
- here, we set the plot `x` axis to the `date` variable, and the plot `y` axis to the `concentration` variable
134
+
- here, we set the plot `x` axis to the `date_decimal` variable, and the plot `y` axis to the `ppm` variable
133
135
- the *geometric object*: specifies how the mapped data should be displayed
134
136
- to create a geometric object, we use a `geom_*` function (see the [ggplot reference](https://ggplot2.tidyverse.org/reference/) for a list of geometric objects)
135
137
- here, we use the `geom_point` function to visualize our data as a scatterplot
@@ -138,7 +140,7 @@ There are many other possible arguments we could pass to the aesthetic mapping a
138
140
the purposes of quickly testing things out to see what they look like, though, we can just go with the default settings:
0 commit comments