Using Git in RStudio

You can read a whole book about Git and R Happy Git with R.

We will not be using Git in RStudio because it can be hard to set-up and hard to debug if you run into problems. If you want to use it, read these instructions.

In particular, read the part about how to set-up so you don’t have to enter your username and password for every commmit.

Alternate methods for downloading repositories

Alternate Method #1 Download from within R

The ‘RWorkflowsetup’ package has a download function. This function will create a folder with the name of the repository. Here is code to download the repository ‘Rmarkdown-Tutorial’. For others, just change the name of the repository.

library(RWorkflowsetup)
repo = "Test"
download.repo(repo)

Alternate Method #2

  1. From RStudio, go to the menu option ‘File->New Project…’. Then from the resulting dialog, choose “Version Control”. Then choose “Git”. Then it asks for a “repository URL”. Supply this: https://github.com/RVerse-Tutorials/Test and leave the “Project Directory Name” empty. And then choose a directory in which to put it and click OK.

  2. Click on the ‘More’ link in the Git Window of RStudio, and click ‘Shell’. Then issue this command.
git remote rm origin

This detaches the cloned repository from the remote repository on GitHub from where you cloned it. That will pull the RStudio project off of GitHub, make a local clone of it on your hard drive and open.

Alternate Method #3

Go to https://github.com/RVerse-Tutorials/Test and click ‘Clone or download’ and chose ‘Download Zip’. Unzip and you’ll probably want to remove ‘master’ added to the end of the repository name.

If you chose, ‘Clone in Desktop’, you’ll need to open a terminal window, navigate to the new folder you just downloaded, and run the git code git remote rm origin from within the terminal to detach the repository from the RVerse-Tutorials GitHub account.

Packages with C++ code

We will not be doing this in this short course, but often you will want to install packages with C++ code. To do that, you will need Rtools (Windows) or Xcode (Mac)

  • Rtools Windows users Rtools also so you can build packages with C++ code if needed. See comments here about changing path. Rtools

  • Xcode Mac users Open terminal and type the following command xcode-select --install