Skip to content

Reviewing Submitted Vignettes in Rstudio

Zhian N. Kamvar edited this page Jun 26, 2016 · 6 revisions

If you want to review a submitted vignette, it's ideal to have the rendered document so that you can see all the output and figures associated with the analysis. This document will show you how to do that via Rstudio and git2r.

Step 1: Open Rstudio and move to a temporary directory

Open up RStudio and then set your working directory in R to a temporary directory:

tmp <- tempdir() # create temporary directory
setwd(tmp)       # go there

If you want to use your files pane to navigate, you can click on the gear icon that says "More" and select "Go To Working Directory".

Using a temporary directory created by R is convenient because R will clean up this directory once we close this session.

Step 2: Clone the contributor's repository

Remember that you will want to clone the repository of the contributor. You can do this with git2r's clone() function. Don't forget to replace USER with the name of the contributor:

library('git2r')
repo <- clone("https://github.com/USER/popgenInfo.git", "popgenInfo") # clone the repository
## cloning into 'popgenInfo'...
## Receiving objects:   1% (36/3542),    9 kb
## Receiving objects:  11% (390/3542),   81 kb
## Receiving objects:  21% (744/3542),  169 kb
## Receiving objects:  31% (1099/3542), 4715 kb
## Receiving objects:  41% (1453/3542), 15587 kb
## Receiving objects:  51% (1807/3542), 31089 kb
## Receiving objects:  61% (2161/3542), 44383 kb
## Receiving objects:  71% (2515/3542), 45775 kb
## Receiving objects:  81% (2870/3542), 45823 kb
## Receiving objects:  91% (3224/3542), 46052 kb
## Receiving objects: 100% (3542/3542), 46070 kb, done.
setwd("popgenInfo/use") # move into the "use" folder.

Step 3: Checkout the branch

Since we work in a GitHub flow model, the new content will always be in a separate branch. At the top of the pull request in GitHub, you'll see under the title (substituting USER for the user name and BRANCHNAME for the name of the branch):

USER wants to merge n commits into NESCent:master from USER:BRANCHNAME

To switch to this branch, simply use git2r's function checkout()

checkout(repo, "BRANCHNAME")

Step 4: Render the document

Rendering by hand

Now that you're in the "use" directory, you can open the document with file.edit("submitted_vignette.Rmd") and then render it using the "knit" button at the top of the file pane. If everything goes smoothly, you should have a rendered HTML document for you to review.

Rendering by code

If you can't be bothered to point and click, here's a solution:

# Render and show the file
rmarkdown::render("submitted_vignette.Rmd")
file.show("submitted_vignette.html")

Troubleshooting

I get an error saying "package not found".

Make sure that you have all the packages required by the vignette to run it.

I get an error saying "could not find function..."

It's a good idea to have your packages up to date when reviewing these vignettes. You can update the packages in the vignette manually OR you can update all of your packages by typing. Be warned: this will update ALL of your packages indiscriminately

update.packages(ask = FALSE)