Differences between rmarkdown files

The diff_rmd function can be used to produce a nicely-formatted document showing the differences between two rmarkdown files. For the purposes of demonstration, we’ll use the example files bundled with the package. We’ll compare modified_file to its earlier version reference_file:

modified_file <- system.file("extdata/CheatSheet-modified.Rmd", package = "reviewer")
reference_file <- system.file("extdata/CheatSheet.Rmd", package = "reviewer")

Compare:

library(reviewer)
result <- diff_rmd(modified_file, reference_file)

And our output:

file1dd4ea9c4db.utf8
---
title: "Git Cheat Sheet"
author: "Amy Stringer"
date: "06/01/2018"
output: pdf_document
---

<!-- this file has been edited just for demonstration purposes within the reviewer package -->

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)TRUE, warning = FALSE)
```

Git is a type of version control software that stores the history of changes made to files in a particular repository. Contained within isThis document contains a brief rundown of the main commands used within the terminal to run git from your personal computer. Towards the end there will be details on how to use git to collaborate with others on files byother people using GitHub.

We can also compare the current version of a document to a previous version in stored in a git repository. (These examples are not run here).

If a reference_file argument is not provided, by default the modified_file will be compared to the most recent copy in the git repo:

result <- diff_rmd(modified_file)

Or we can compare it to how it appeared in the git repository after a particular commit (here, the commit with reference 750ab4):

result <- diff_rmd(reference_file, "750ab4")

Annotating web pages

Anyone can view annotations, but to fully use the annotation functionality and add your own annotations an account is needed at the Hypothes.is website. Annotations can be enabled by using the RStudio addin Insert html annotation js snippet. Annotations have even been enabled for this document! It works by adding the following javascript snippet to the bottom of your RMarkdown document:

<script src="https://hypothes.is/embed.js" async></script>