Posted on 3 minute read

Windows 10 is a totally capable platform for developing R applications and packages and collaborating with others on Github. You just need to install and configure the right tools.

R

First (duh!) you need to install R. Download an installer from the Windows downloads page. If you’ve already installed R but are not on the latest released version, it’s not a bad idea to uninstall what you have and install the latest.

RTools

Download the version of RTools corresponding to the version of R you just installed and run the installer.

The default selections are all fine, except one: make sure the checkbox labeled “Add rtools to system PATH” is checked when you see it.

If you don’t select this option, you will have problems building R packages in RStudio later.

RStudio

The RStudio IDE works nicely on Windows and can be downoloaded for free.

Chocolatey

Chocolatey is a package manager for Windows that facilitates installing and upgrading free software like git and ssh, which are two tools I suggest installing.

To install it, just follow the instructions.

git

Now that you’ve installed Chocolatey, installing git is a cinch. In an Administrative PowerShell window, run the following commands:

choco install git

ssh (optional)

On Github, you have the option of cloning repositories using either HTTPS or SSH. I personally prefer SSH, because I clone repos all the time and I don’t like to be constantly prompted for my username and password.

If you’re new to git and Github, I suggest skipping this step. Otherwise, you can install ssh with choco install openssh.

Configure git

Windows uses a different character than Mac or Linux to represent the end of a line — the character inserted when you press Enter — which can make it difficult to collaborate on text files with users on a different platform.

For those on Windows, git can be configured to automatically to handle this difference by running the following command in a (non-Administrator) PowerShell:

git config --global core.autocrlf true

For details on this setting, check out the Github documentation on the subject.

Configure RStudio to use git

Now that git is installed and configured, you can configure RStudio to use it. This will allow you to drive git from RStudio, without necessarily using the command line.

  1. Open RStudio
  2. Under the Tools menu, select Global Options
  3. Click on Git/SVN in the resulting Options window
  4. Select Enable version control interface for RStudio projects
  5. Next to Git executable click Browse
  6. Navigate to C:\Program Files\Git\bin\git.exe and click Open. This is where Chocolatey installed git.
  7. Click the Apply button and restart RStudio

Now in RStudio, you should see a tab called Git in the top right quadrant of the window. This tab is the entrypoint for staging, diffing, committing, and pushing to Github.

Additionally, you can now use RStudio to clone projects from Github:

  1. Under the File menu select New Project
  2. On the resulting window select Version Control
  3. On the window after that, select Git, and paste in the clone URL from the project’s Github page

Conclusion

Congrats! You’re all set up to develop R applications, develop R packages, and interact with Github with the best of’em. From here, you can install standard R tools like the devtools and usethis packages.

For an introduction to R package development, RStudio’s Developing Packages with RStudio is a good introduction.

Thanks for reading, I hope you have fun writing and sharing code!