Motivating literate programming

Why R Markdown?

  • R Markdown allows you to seamlessly combine executable R code, its output, and text in a single document.
  • These documents can be converted to multiple static and dynamic output formats, including PDF (.pdf), Word (.docx), and HTML (.html).
  • The benefit of a well-prepared R Markdown document is full reproducibility.

Demo

  • Open documents/countryPick4.Rmd

  • Scroll down until you see the following code chunk:

countryName1 <- "India"
countryName2 <- "United States"
countryName3 <- "Nigeria"
countryName4 <- "Germany"
  • Replace the country names within the quotation marks with any country of your choice, using the exact name from the list of countries shown on the presentation screen.

  • Knit the document

  • See how the report generated all results for the countries you chose

Now let’s create an Rmd report from scratch