geom_line(aes(y = CO2), color = "gray60", size = 0.5) +
geom_line(aes(y = trend), color = "blue", size = 1.2) +
scale_x_continuous(
limits = c(1958, 2025), # x-axis range
breaks = seq(1960, 2025, by = 5) # tick marks every 5 years
) +
labs(
title = "Long-Term Trend in CO2 Concentration",
x = "Year", y = "CO2 (ppm)"
) +
theme_minimal()
This is an R Markdown document that you can easily export to HTML, PDF, and MS Word formats. For more information on R Markdown, see <http://rmarkdown.rstudio.com>.
p1
```
```{r}
#2.2. Find a simple model for the slow contribution, estimate its parameters,
#and attempt an extrapolation until 2025 (for validating the model using future observations).
When you click on the button **Knit**, the document will be compiled in order to re-execute the R code and to include the results into the final document. As we have shown in the video, R code is inserted as follows:
summary(season_model)
```{r cars}
summary(cars)
df_clean$time <- df_clean$DecimalDate
```
It is also straightforward to include figures. For example:
```{r pressure, echo=FALSE}
plot(pressure)
```{r}
# Create new data from last year to 2030
future <- data.frame(time = seq(from = max(df_clean$time), to = 2030, by = 1/12))
# Trend of the CO2 (ppm) predicted from 2025 to 2030 year
ggplot() +
geom_line(data = future, aes(x = time, y = trend), color = "blue") +
geom_line(data = future, aes(x = time, y = CO2_predicted), color = "red") +
labs(title = "CO2 Projection with Trend + Seasonal Model",
y = "CO2 (ppm)", x = "Year") +
theme_minimal()
```
Note the parameter `echo = FALSE` that indicates that the code will not appear in the final version of the document. We recommend not to use this parameter in the context of this MOOC, because we want your data analyses to be perfectly transparent and reproducible.
```{r}
# the inceasing of the CO2 (ppm) predicted within 2030 year
ggplot() +
geom_line(data = df_clean, aes(x = DecimalDate, y = CO2), color = "black") +
geom_line(data = future, aes(x = time, y = CO2_predicted), color = "darkgreen") +
geom_vline(xintercept = 2023, linetype = "dashed", color = "red") +
annotate("text", x = 2023.5, y = max(df_clean$CO2),
breaks = seq(1960, 2030, by = 5) # tick marks every 5 years
) +
labs(
title = "CO2 Prediction Until 2030",
x = "Year", y = "CO2 (ppm)"
) +
theme_minimal()
```
Since the results are not stored in Rmd files, you should generate an HTML or PDF version of your exercises and commit them. Otherwise reading and checking your analysis will be difficult for anyone else but you.
Now it's your turn! You can delete all this information and replace it by your computational document.
Note: write your solution in the file module3/exo3/exercice_en.Rmd.
Generate a PDF file using the KnitR tool and store it as module3/exo3/YourFileName.pdf (don't forget to commit it).