Tag Archives: dropbox

Using dropbox with R

I like to use dropbox for online storage and syncing of R code and data that I am using at home and at work. Storing the code in the cloud means I always have access wherever I am, and that I don’t have to remember to bring my USB flashdrive to and from work.

My work computer (Windows XP) and my home computer (Ubuntu Linux) store their dropbox folders in different locations, meaning that calls to the R function setwd() will work on one of my computers, but not the other.

This chunk of R code checks which operating system R is being run under, and sets the working directory appropriately. I’m sure there are more elegant ways to fix this problem, but this approach works for me.

if(Sys.info()[1]=="Linux") {setwd("/home/michael/Dropbox")} else
                           {setwd("D:/Dropbox/My Dropbox")}