An Introduction to R and RStudio

Advanced Issues

Here I want to mention several issues that I have come across when working with R/RStudio on ‘work’ or institute computer systems (read: systems that are ‘locked’ down and you have very little freedom). There are ways around these issues to a certain extent, but the best advice I can give you is to befriend someone in IT and try to get it sorted at that end – this will save you a lot of time and grief. If this is not an option, then feel free to try some of these tips and tricks.

Note: these tips/tricks will only be required if you are using R on a system that is not your own, or if the network you are using requires proxy, or admin privileges, i.e. I wouldn’t recommend using the internet/proxy adjustment lines on your home desktop or laptop in less you know what you are doing!

Proxies and package updates

Depending on the network options setup on the system you’re working on, your mileage may vary when trying to download and install packages. If you are having issues here are several functions that I have found that might help out somewhat:

# Set or disable the use of Internet Explorer for Internet access.
# this can sometimes allow you to enter your site proxy details (read on...)
utils::setInternet2()
# set environmental condition for proxy access
# for most places the default port is 8080
Sys.setenv(http_proxy="http://myproxy.info.co.nz:8080 http_proxy_user=ask")
# you’ll need proxy address and port number (and of course user name and password!)

Note: if you have a different port, get hold of IT and ask them which one you should be using.

Permissions and write protection

The default R library directory is within the main R installation (as mentioned previously). Sometimes, depending on the rights/privileges, this folder will be inaccessible and/or write protected – meaning that you won’t be able to install packages there. Great. Well you might be thinking ‘this isn’t too much of an issue as I’m using RStudio’, you’d be semi-correct. With RStudio you can create a default library in the user directory of the system you are working on, but sometimes it might not be listed as the default library for package installation. Luckily we can set the default library with ease:

.libPaths()                         # lists current library paths
.libPaths("C:/users/mbenton/R/win-library/2.13")    # will add desired location to .libPaths
# if all else fails this usually works:
install.packages(kinship2, lib="C:/users/mbenton/R/win-library/2.13")
# set lib="" to your desired library