HW8 - R Markdown Exercises

3 minute read



Learning R Markdown

To get started with the following homework tasks, log in to your HPCC account and then cd into /bigdata/gen242/<user_name>. Then clone your new project repos linked under your name in Colum J (2nd sheet) of the Course Planning Sheet linked from Canvas here. After this, cd into your project’s repos and create as subdirectory called HW8. Subsequentially, download into the HW8 directory with wget the sample.Rmd and bibtex.bib files linked from the R Markdown Tutorial here. Next, make the following changes (Tasks 1.-8.) to the downloaded R Markdown (Rmd) file. After this render the modified Rmd to HTML format, and then submit both files to your project repos on GitHub. The changes to include in the R Markdown are:

Homework Tasks

  1. At the beginning of the R Markdown report, add a short section describing the analysis steps you have chosen to perform as part of your challenge project.
  2. In the challenge project section, cite the reference(s) of the paper(s) you have chosen to present in class as part of your course project. For this add the reference in BibTeX format to the downloaded bibtex.tex file, and then cite it in the text of the Rmd file so that the properly rendered citation shows up in the text and the corresponding reference is automatically added to the reference list at the end of the R Markdown when running rmarkdown::render. Note, references in BibTeX format can be obtained from Google Scholar, Paperpile or most other reference management software. More detailed information about managing references in R Markdown files is here.
  3. Add a mathematical equation in LaTeX format to the challenge project section and make sure it renders properly when generating the HTML report.
  4. Evaluate an R expression in the text as inline R code (see here) of your challenge project, e.g. mathematical or number from an existing R oject such as mean value of the first column of the iris data.frame.
  5. Add a code chunk that auto-generates the barplot for HW3C. This barplot should be embedded in the rendered report without saving it intermediately to a file.
  6. Insert the targets file of your workflow (default toy data is sufficient) as an interactive table using the DT package. An example is given in the table section of the R Markdown manual here.
  7. Use the rmarkdown::render() function to render the report to an HTML file (details are here). Important: for this assignment it is not relevant to evaluate the code chunks for the actual analysis steps of the analysis workflow. Only the chunks required for the above tasks need to be evaluated. Also, when embedding the targets file under step 6 into the report, the interactive table generated by the DT package can only be included in the HTML version of the report. To including this table in the PDF version of the report, use the static knitr::kable option instead as outlined here.
  8. Submit the Rmd and HTML files for the report to the corresponding project repos on GitHub. Remember the details for adding, committing and pushing new files to a GitHub respos are given in the GitHub tutorial of GEN242 here.

Homework submission

Please submit both the final Rmd and HTML files, where the above Tasks 1-8 have been fully addressed, to the HW8 subdirectory of your project repos on GitHub.

Due date

This homework is due in one week on Thu, May 19th at 6:00 PM.

Homework Solution

All solutions for HW08 can be looked up in the R Markdown tutorial of this class. The source code is available in the Rmd file and the rendered result in the corresponding HTML file. As in all tutorial pages of this site, the Rmd files can also be accessed via a link located in the header section of each tutorial page.

Last modified 2022-05-12: some edits (d9ef27d21)