---
title: "HW8 - R Markdown Exercises"
linkTitle: "HW8: R Markdown"
description: >
type: docs
weight: 308
---
## Learning R Markdown
To get started with the following homework tasks, log in to your HPCC account
and then `cd` into `/bigdata/gen242/`. Then clone your new project
repos linked under your name in Colum J (2nd sheet) of the Course Planning Sheet linked from Canvas [here](https://elearn.ucr.edu/courses/91826).
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](https://girke.bioinformatics.ucr.edu/GEN242-2021/tutorials/rmarkdown/rmarkdown/#initialize-a-new-r-markdown-rmd-script).
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](https://girke.bioinformatics.ucr.edu/GEN242/tutorials/rmarkdown/rmarkdown/#citations-and-bibliographies).
3. Add a [mathematical equation](https://girke.bioinformatics.ucr.edu/GEN242/tutorials/rmarkdown/rmarkdown/#mathematical-equations) 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](https://girke.bioinformatics.ucr.edu/GEN242/tutorials/rmarkdown/rmarkdown/#inline-r-code)) 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](https://girke.bioinformatics.ucr.edu/GEN242/tutorials/rmarkdown/rmarkdown/#r-code-chunks) that auto-generates the barplot for [HW3C](https://girke.bioinformatics.ucr.edu/GEN242/assignments/homework/hw03/hw03/#c-bar-plots). 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](https://rstudio.github.io/DT/). An example is given in the table section of the R Markdown manual [here](https://girke.bioinformatics.ucr.edu/GEN242/tutorials/rmarkdown/rmarkdown/#with-dtdatatable).
7. Use the `rmarkdown::render()` function to render the report to an HTML file (details are [here](https://girke.bioinformatics.ucr.edu/GEN242/tutorials/rmarkdown/rmarkdown/#render-rmd-script)). 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](https://girke.bioinformatics.ucr.edu/GEN242/tutorials/rmarkdown/rmarkdown/#with-knitrkable).
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](https://girke.bioinformatics.ucr.edu/GEN242/tutorials/github/github/#exercise).
## 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 30th at 6:00 PM.
## Homework Solution
All solutions for HW08 will be posted after the due date.