Part 2

start with copying in this table

co2 <- read.table("co2_mm_mlo.txt",
                  col.names = c("year", "month", "decdate", "average",
                                "interpolated", "trend", "ndays"))

Create a vector containing all CO2 concentrations for all years up to and including 1985 (Use the column headed ‘interpolated’ for the CO2 values) to start this we need to create a yearID using the which() function

yearID = which(co2$year <= 1985)

with the yearID we can create a varible and a vector

co2_pre86 = co2[yearID, ]

now we do the same thing for the year following 1985

yearID = which(co2$year > 1985)
co2_post86 = co2[yearID, ]

lastly we need to estimate the mean co2 concentration for these vectors we do this using the mean() function and $interpolated at the end to signify which column we want to use

mean(co2_pre86$interpolated)
## [1] 328.5344

same thing for post

mean(co2_post86$interpolated)
## [1] 376.5662