Steps to preparing and submitting assignments

Follow these steps for EVERY assignment:

  • Create a new RStudio project in a suitable folder (preferably on your UBC network F: Drive)
    • For a reminder on how to create an RStudio project, go back to this tutorial
  • For each assignment you will download from Canvas a Markdown assignment file (with a “.RMD” file extension)
    • This Markdown document includes the assignment questions, and serves as a starter template for your assignment.
    • An example file is available here
  • Immediately re-save the Markdown document using “save as”, to change the the file name as needed (eg. “Lab_01_lastname”)

  • Into that same working directory, place a copy of the Word style template document entitled “assignment_style_template.docx”, accessible here
    • this same Word file can be used for all assignments (it simply tells Markdown what “styles” to use when knitting the Word document)
  • Answer the assignment questions in the newly saved Markdown document.

  • Save your Markdown document frequently, and also attempt to knit your document to Word frequently

  • Once you have completed your assignment, be sure to check all your spelling, and that figures / tables are appropriately formatted etc…

  • Knit your Markdown document to Word

  • Open up the resulting Word document, check that everything looks good; if NOT, then close the Word document, and go back into the Markdown document to make any edits; once complete, re-Knit the document to Word

  • Use the “Save as” menu option in Word to save your document as a PDF file, using the same naming convention (“Lab_xx_lastname”), where “xx” is the lab assignment number, and “lastname” is your own last name

  • Open up the PDF document, and verify that it looks correct

  • Submit your PDF document to the appropriate place in Canvas

  • Verify afterwards that your PDF document did indeed upload correctly


Answering assignment questions

  • You must answer clearly and in full sentences. Make sure you answer the question explicitly.

  • Show the code you used to answer the question, as well as the output from that code (knitting does this automatically)

  • Describe what you did- explain (briefly) your rationale/thought process

  • DON’T FORGET to include figure captions for every figure

  • If you use a graph to answer a question, refer to that graph in your answer!

Example question / answer

Question 1. What are the minimum and maximum petal widths of flowers in the iris dataset?

Answer: I used favstats() to calculate some descriptive statistics for petal widths in the iris dataset. As shown in the output below, the minimum petal width was 0.1 cm and the maximum petal width was 2.5 cm.

##  min  Q1 median  Q3 max     mean        sd   n missing
##  0.1 0.3    1.3 1.8 2.5 1.199333 0.7622377 150       0

Guidelines for data presentation

Consult the Biology guidelines for data presentation document here.
Formatting tables and figures properly takes time and skill. For now, we’re only going to focus on proper figure and table headings.


Setting up R Markdown for graphing

There are some special options that need to be set in your Markdown document in order to:

  • include Figure captions with your figures (a necessity!)
  • set the dimensions of your figures

These settings will be included in your R Markdown assignment template documents.

In each R chunk that includes code to construct a graph, your chunk options should look like this in the top of the chunk:

{r fig.cap = "Figure caption here", fig.width = 3, fig.height = 4}

Generating nice tables using R Markdown

There is a tutorial on this here.


Symbols and notation in R Markdown

There is a tutorial on this here.