## Files and Folders

It is essential that you name your folders and files exactly as specified. We run checks like

cd HW2
Rscript -e 'rmarkdown::render("hw2.Rmd")'

from the top of a clone of your repository. If the folders and files are not named exactly as specified these checks will fail and your work will not be graded.

## Rmarkdown Usage and Coding Style

Make sure you are using Rmarkdown properly, with explanatory texts surrounding short code chunks. In particular you should not have just one big code chunk.

Your rendered HTML page should be a report with text supporting numerical and graphical results. Code only needs to be visible if you are explaining how to do something (which is a goal of the class notes).

## Name and Date

Make sure your Rmarkdown file header contains a name: field with your name. A date: field with an appropriate date is also helpful.

---
title: "HW2"
output: html_document
date: "February 1, 2022"
---

You can also use one of these as the date line to produce the current date when the document is knit:

date: "r Sys.Date()"
date: "r format(Sys.Date(), '%B %e, %Y')"

## Reproducibility

Make sure your .Rmd file will knit without errors.

• Except for packages your code should not depend on anything not contained in your repository.

• Your code should not attempt to make any modifications outside your repository, including installing packages.

## Handling Data Files

If your Rmarkdown document makes use of an external data file you need to make sure it can be accessed when someone you give your repository to renders your file. There are several options:

• Include the file in your repository. You can then reference it from your code with a relative path, relative to the location of your Rmd file. This is reasonable for small data sets and it freezes the data at its current state.

• Access the file using a URL. This will load the file over the network each time you render your document. You need a network connection, and you may cause unnecessary traffic if the file is large.

• Check if you have the file locally, and download it if you do not. This is often a good option and there are several example of how to do this in the notes.

Relying on retrieving a file from the network means it may change or be removed. In some cases this will be what you want, in others maybe not.

## Avoiding Messages and Warnings in Output

Some packages produce messages when they are loaded and some computations produce messages or warnings. In a final report you usually do not want these to be visible. You can suppress messages, like the ones produces when loading the tidyverse by adding the chunk option message = FALSE. Warnings can also be suppressed with the chunk option warning = FALSE, but it is usually better make sure you understand where the warnings are coming from and modify your code to avoid them (e.g. by adding na.rm = TRUE to some calls).

## 1. Average Infant Mortality Rate Continent in 2015

The following table shows the average infant mortality rate, in deaths per 1000 live births, for 2015 across countries in five continents as defined in the gapminder data set from the dslabs package.

Continent Infant Mortality
Africa 48.0
Americas 15.6
Asia 18.6
Europe 4.5
Oceania 22.0

Infant mortality for Africa is still quite a bit higher than for the other continents.

## 2. Average Infant Mortality Rate Over the Years

This graph shows average infant mortality rate over the years for the five continents defined in the gapminder data set from the dslabs package.

All continents show a decrease in infant mortality over time. The curve for Africa is noticeably higher than the curves for the other continents. The bump for 1990-2000 in the Africa curve reflects famine events and conflicts in Africa during these years.

## 3. Mauna Loa Atmospheric CO$$_2$$ Concentration

This plot shows the yearly average CO$$_2$$ concentration measured at the Mauna Loa Observatory in Hawaii. Measurements are in parts per million.

CO$$_2$$ levels have been rising consistently over the years, with the rate of increase appearing to rise slowly as well.