Skip to content

Instantly share code, notes, and snippets.

@amandamiotto
Created June 26, 2018 03:34
Show Gist options
  • Save amandamiotto/34f41296e1e54cdc9c91e72b8204b86e to your computer and use it in GitHub Desktop.
Save amandamiotto/34f41296e1e54cdc9c91e72b8204b86e to your computer and use it in GitHub Desktop.
Tips for setting up R packages on windows 10
#Written by Chris Brown at Griffith Uni
#Tips for setting up R packages on windows 10
I recommend installing packages to your local drive, not the shared network drive. Though R will default to the network drive (which is "\\\\staff\..."), so some knowledge is required to overcome this.
You could also ask IT to bind a letter to your network drive. I've read that works (see here: https://github.com/r-lib/devtools/issues/353)
Here's the steps I followed to install packages:
Create a shortcut to R on desktop.
Right click it
Select properties then security tab.
Then give yourself permission for "Full control" and "Modify"
Then use this shortcut to install packages. Most packages can just be installed normally, but some packages that are widely used by others will only be found if installed to the C drive.
So I opened this shortcut and used:
install.packages(c("Rcpp", "RcppArmadillo"), lib = .libPaths()[2], dependencies = TRUE)
The command ".libPaths()[2]" ensures it installs to C drive, not the Y drive.
to install such packages (examples are Rcpp, RcppArmadillo, dplyr, tidyr, ggplot2 etc)
#Installing Rtools
You will need Rtools to compile packages from source. e.g. if you want to get packages off of github, or there isn't source available on cran.
Go to https://cran.r-project.org/bin/windows/Rtools/ and get the latest Frozen version.
Now run the .exe to install. Make sure you click the tick box to modify the PATH.
To check it has worked open R and type:
Sys.getenv('PATH')
There should be some directories for Rtools in the returned text.
I had troubles with getting Rtools to install, it seemed it would install fine, but couldn't modify the PATH. So I had to get IT to come and give me admin rights. Then the install worked.
The source package I was trying to install also relied on Rcpp and RcppArmadillo, which I had to reinstall as above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment