RMarkdown basics

RMarkdown files (.Rmd) are a combination of R (or Python) code blocks and the writeup language called Markdown, which is itself based on HTML, the basic language of webpages. Using RMarkdown allows us to write in regular prose as well as write executable code in code blocks.

It also allows us to export that prose and code as a familiar format like .docx (Microsoft Word), .pdf (Adobe), and .html (website). In our case, you will be exporting your portfolios as a quite stylish .html.


This is the Source view showing the raw code including the frontmatter information (between the โ€œ—โ€) and different types of inputs.

This is the Visual view showing a preview of what the final published .html document will look like. You can edit while in this mode, but I suggest getting use to working directly with the Source.


To export the completed .Rmd file, press the โ€œKnitโ€ button on the top bar.

If it is a new file, you will be prompted to name your file. Once you have named it, press โ€œSaveโ€.

Once it is exported, your .html file will open automatically by RStudio. You can also look at it on your browser by clicking โ€œOpen in Browserโ€

You can save your exported .html file by checking the file under “Files” on the bottom-right pane, then click on “Export” in the More menu. You can then download the file to your computer or an external drive. That file can be submitted to Brightspace.

Every week, there will be a .Rmd “portfolio” due that is based on the content from the previous week. The purpose of these portfolios is:

  1. To give you an opportunity to work on the course content further at home
  2. Get use to using R and RMarkdown outside of the classroom
  3. Give you a set of examples of statistical tests that you can reference and use in the future – including graduate school, med school, or in your profession.

The portfolios need to be submitted as an .html file by 8 am on the day that they are due (see Syllabus) on Brightspace under “Assignments”. Scores on portfolios will be based on the following rubric:

Criteria 5 4 3 2
1
Code quality
The code is well-written, well-organized, and easy to understand. The code is mostly well-written and well-organized, but with minor errors or issues.

The code is partially well-written and well-organized, but with significant errors or issues. The code is poorly written and poorly organized, with multiple errors or issues. The code is not written in a clear, organized or structured way.
Correctness
The code correctly implements the statistical methods and analyses specified in the assignment, and produces accurate and correct results. The code mostly correctly implements the statistical methods and analyses, but with minor errors or inaccuracies. The code partially correctly implements the statistical methods and analyses, but with significant errors or inaccuracies. The code does not effectively implement the statistical methods and analyses, with multiple errors or inaccuracies The code does not attempt to implement the statistical methods and analyses.
Data handling
The code properly handles the input and output of data, including checking for errors and missing values. The code mostly properly handles the input and output of data, but with minor errors or issues. The code partially properly handles the input and output of data, but with significant errors or issues. The code does not effectively handle the input and output of data, with multiple errors or issues. The code does not attempt to handle the input and output of data.
Questions
The student answers all questions completely and accurately, providing detailed explanations and demonstrating understanding of the material. The student answers most questions completely and accurately, but with minor errors or omissions. The student partially answers questions, but with significant errors or omissions. The student does not effectively answer questions, with multiple errors or omissions. The student does not attempt to answer questions.

This rubric is also attached to each assignment drop box on Brightspace.