The Mauna Loa data provide an opportunity to gain experience applying basic exploratory data analysis.

Activities today

  1. Continue basics for computing in R
  2. Explore data on CO2 and climate

For next class

Based on your first day with the Mauna Loa vignette, provide a short summary for the following:

  1. What time of year is CO2 highest/lowest and why?
  2. At the current rate of CO2 increase in the atmosphere, how many years of change in the mean is equal to the seasonal change in CO2.
  3. The Mauna Loa CO2 series is an example of passive surveillance data that became one of the important debates of modern times. List three ways that this data set bears on the litigation issues we discussed on big oil.
  4. The ice-core data tell us that CO2 has been fluctuating for a long time. How does that perspective inform the interpretation of contemporary increases? Specifically, does it bear on the question of responsibility for the societal cost of climate change?

Post your answers to Sakai.

Recall basics in R

The Mauna Loa data analysis can be completed by cutting and pasting code. The Intro to R explains and provides practice on using them.

These basic objects came up last time:

Some common questions:

Yes, I like this site.

No single answer for this, but always consider the following: i) restart, ii) update Rstudio, iii) google the error message. Also, bring these issues to class.

This operator is a function that is explained, among other places, in the package magrittr. As with many things in R, there can be multiple routes to the same result.

You can use the function save(), which saves everying to a .Rdata file. However, better still is to save the code as you write it in a .r file, so you can recreate it.

We can discuss loading multiple objects with load(filename) along with other ways to read and write objects.

CO2 at Mauna Loa

Here are a few thoughts as you work with R.

mauna_loa_weekly <- read.table('ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_weekly_mlo.txt')
  1. Explore the object created by read.table
  1. Where did this object come from?

  2. Use the function mode to determine the storage mode.

  3. Use the function sapply to determine the storage mode of each column.

  4. Use the function colnames to find the column names of mauna_loa_weekly

  5. create a vector to extract columns 1, 2, 3, and 5

  6. extract these columns from mauna_loa_weekly; use the dim function to determine its size.

  7. the new names for these columns will be ‘year’, ‘month’, ‘day’, ‘co2ppm’. Use the colnames function to assign these names to mauna_loa_weekly

  1. Dates have functions to handle year, month, and day.
  1. first, use paste to combine (as characters) the year, month, and day columns separated by the string '-'.

  2. use asDate with format = '%Y-%m-%d' to generate a date column in mauna_loa_weekly.

  3. use which to locate values of co2ppm == -999.99 and replace them with NA.

  4. use lm to regress the variable co2ppm against date. Interpret the fitted coefficients.

  1. Generate a plot of co2ppm against date using plot; add labels for x and y axes.

##                           Estimate   Std. Error   t value Pr(>|t|)
## (Intercept)           3.174447e+02 1.532608e-01 2071.2711        0
## mauna_loa_weekly$date 4.991952e-03 1.310012e-05  381.0615        0
##                 Estimate  Std. Error   t value     Pr(>|t|)
## (Intercept) 3.202189e+02 2.025843697 158.06695 2.870707e-15
## x           4.668642e-03 0.000258499  18.06058 9.067222e-08