This is a simple homework assignment template using R Markdown.
Notice that in the previous line we can create a header for our problem number by using a single “#”. The text is then automatically bolded and indented. Below we will create a sublist. This should be used if problems have more than one part.
Suppose we need to input an R chunk into our homework file. In this case, the following syntax should be used. Note that “’’’” signifies we are include chunks of code (We may also tweak the options as necessary). In this template, all the code chunks are folded (by default), you can change the look by changing the code_folding parameter (at the beginning of the *.Rmd) or clicking the fold/unfold button (at the top of the *.html).
# input R code here. Examples: define R list
x = c(1, 2, 3, 4, 5)
# make plot
plot(x)
Below the R code, we can provide additional descriptions and/or explain our code more thoroughly.
# again, we can input our R code here.
R Markdown extends the Markdown language. It lets you include nicely-typeset math, hyperlinks, images, and some basic formatting. The R Markdown Quick Tour and Introduction to R Markdown show you how to write an R Markdown report in RStudio.
For creating homework/project reports, check out this guide to learn how to use its most essential features.
R Markdown Cheat Sheet is a two-slide reference guide. (Search online and you’ll find various versions – see which one you like.)
For other useful resources, check out Learn R Markdown.
This document was adopted from several good resources: Prof. Debdeep Pati’s homework template, Prof. Nathan Taback’s Using R Markdown for Class Assignments (which was adopted from Cozma Shalizi’s guide).