Assignments should be submitted through RMarkdown “worksheets.”
After each class, a worksheet will be available for download on the course page. This worksheet contains exercises with blanks for you to fill in with your code or solutions. Upon completing an assignment, you should upload it via the course page.
What is RMarkdown?
RMarkdown is a file format that integrates text, code, and the results of code execution (tables, printouts, figures, etc.).
One of the best actions you can take is to become acquainted with RMarkdown:
https://rmarkdown.rstudio.com/lesson-1.html
Essentials of RMarkdown for Assignment Submission
- RMarkdown documents utilize Markdown syntax. Here are some Markdown basics:
# This is a top-level header (counterpart of <h1> in HTML)
## This is a second level header
*This text will be in italic*, **this text will be in bold**, ***and this will be in both italic and bold***.
1. Ordered lists are automatically numbered.
3. The numbering in the source file is irrelevant
* You can create hierarchical lists
* no biggie
- Embedding R code in RMarkdown documents is straightforward:
```{r}
hist(rnorm(200)) # histogram of 200 random numbers from a normal distribution
# The backticks that start and end a code block are typed using the tilde key (`~`), not the single quote key (')
# Remember, backticks are not apostrophes!
```
R can “knit” RMarkdown documents, which involves executing R code in code blocks and compiling the document into HTML/DOCX/PDF format with the execution results. To knit an RMarkdown document, click the “Knit” button in RStudio. All assignments MUST knit successfully.
Your working directory during an interactive R session can be identified using the getwd function. When knitting an RMarkdown document, the working directory is set to the location of the RMarkdown file. This detail is crucial.
The best way to save everyone’s effort is to put all files with data and the RMarkdown file in the same directory. Then, you will be able to read it using just
read.csv("filename"). I will be knitting your files and I hate deleting or changing all paths (C:\\Users\\blahblah\\yaddayadda\\...).Avoid using the
install.packagesfunction in your RMarkdown file, even if you are using a less common library. Assume that I have all existing R libraries installed (which is the case) and simply load them withlibrary.Ensure your RMarkdown files are saved with the correct encoding (UTF-8, refer to Troubleshooting).