Question: 3. In a previous exercise, we created a tidy version of the co2 dataset: co2_wide % setNames(1:12) %>% mutate(year = 1959:1997) %>% pivot_longer(-year, names_to =
3. In a previous exercise, we created a tidy version of the co2 dataset:
co2_wide <- data.frame(matrix(co2, ncol = 12, byrow = TRUE)) %>% setNames(1:12) %>% mutate(year = 1959:1997) %>% pivot_longer(-year, names_to = "month", values_to = "co2") %>% mutate(month = as.numeric(month)) We want to see if the monthly trend is changing so we are going to remove the year effects and then plot the results. We will first compute the year averages. Use the group_by and summarize to compute the average co2 for each year. Save in an object called yearly_avg.
4. Now use the left_join function to add the yearly average to the co2_wide dataset. Then compute the residuals: observed co2 measure - yearly average.
5. Make a plot of the seasonal trends by year but only after removing the year effect.
You can find the Co2 data in (tidyverse) package. I know that I can only post one questions but theses three questions are related to each others.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
