R Package Development on Windows
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.
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.
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.
The RStudio IDE works nicely on Windows and can be downoloaded for free.
Chocolatey is a package manager for Windows that facilitates installing and upgrading free software like
ssh, which are two tools I suggest installing.
To install it, just follow the instructions.
Now that you’ve installed Chocolatey, installing
git is a cinch. In an Administrative PowerShell window, run the following commands:
choco install git
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
choco install openssh.
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 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.
- Open RStudio
- Under the Tools menu, select Global Options
- Click on Git/SVN in the resulting Options window
- Select Enable version control interface for RStudio projects
- Next to Git executable click Browse
- Navigate to
C:\Program Files\Git\bin\git.exeand click Open. This is where Chocolatey installed
- 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:
- Under the File menu select New Project
- On the resulting window select Version Control
- On the window after that, select Git, and paste in the clone URL from the project’s Github page
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
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!