Skip to main content
Purdue University Purdue Logo Purdue Libraries

R for Molecular Biosciences: Rmarkdown

The guide was created to support the course, R for Molecular Biosciences, an introductory undergraduate course in data science.

Rmarkdown Formatting

The basic file formats that you can use for your R code are described on the R and RStudio page of this guide. 

All assignments in this class will be written in Rmarkdown then 'Knit' (rendered) to an HTML report.  To succeed in this class, you must become proficient with the basics of Rmarkdown, i.e. subject headings, table of contents, text emphasis, small tables, linking webpages, embedding images, including executable code and including narratives that clearly explain the objectives of your project and what your code is doing. 

To understand how Rmarkdown works, I suggest that you read the Preface to Rmarkdown: The Definitive Guide,

There are two cheat sheets posted below that should open in the browser.  The first is from RStudio, and this is the file that is linked through RStudio > Help > Cheatsheets.  It is pretty complicated but comprehensive.  The most important parts are 'IMPORTANT CHUNK OPTIONS' and 'Pandoc's Markdown'. 

The next two files are a basic cheat sheet created by a computer science student at Purdue.  You should view these files in parallel.  The Rmarkdown format file shows you what Rmarkdown syntax you need to use to produce the Cheat Sheet HTML version.

File Formats for RStudio

Rmarkdown Optional HTML Formatting

The cheat sheets above cover the basics of Rmarkdown and HTML document preparation.  You do not need to go beyond the basics to succeed in the course.  However, some students like to personalize their project or course notebook.  If you are curious, browse the the HTML document chapter,, in the free online book, Rmarkdown, The Definitive Guide.  This will chapter will show you how to tweak your table of contents, use tabsets, or change the output style. 

There are several themes and styles that are already built-in to RStudio.  The list can be found in the guide here,  These themes are drawn from the Bootswatch library,

One final tip, if you know HTML, you can include HTML tags in your Rmarkdown document.  These will be used to render your HTML document.  For example, you can insert a page break into your HTML report. 

<p style="page-break-before: always">

This break will not be apparent unless you print a hardcopy of your report.