R and Dropbox

April 15, 2013
By

(This article was first published on Eran Raviv » R, and kindly contributed to R-bloggers)

When you woRk, you probably have a set of useful functions/packages you constantly use. For example, I often use the excellent quantmod package, and the nice multi.sapply function. You want your tools loaded when R session fires.

In order to automatically load your objects into the session you can:
1. Customize your startup using “.Rprofile”.
2. Make a “UsefulObj.r” file for each project and source it.

I do not use (1). Using (2) with the excellent Dropbox product cluttered my scripts like so:
# source("Location 1/Dropbox/UsefulObj.r")
# source("Location 2/Dropbox/UsefulObj.r")

and would uncomment according to the computer I was working on. Two lines for every file, clearly not the best practice.

I recently noticed few posts with joint R and Dropbox subject matter.
Tal Galili: syncing-files-across-computers-using-dropbox
The bioBucket: download-files-from-dropbox
Christopher Gandrud: dropbox-r-data
Michael Scroggie: using-dropbox-with-r
Karthik Ram: relevant Git (from the bioBucket’s comments). It is an R-package called rDrop: Dropbox interface via R.

I was not really aware of those, my solution is scriptly primitive.
Nchars = unlist(regexec("x",getwd())) + 1 # x for the last char in dropbo-x.
file1 =
paste(substr(getwd(),start = 1,stop=Nchars),"UsefulObj.r",sep = "")
file2 =
paste(substr(getwd(),start = 1,stop = Nchars),"UsefulObj.r",sep = "")

FilesToLoad = c(file1,file2)
sapply(FilesToLoad,source,.GlobalEnv) # Source these files

My two cents (EURO).

To leave a comment for the author, please follow the link and comment on his blog: Eran Raviv » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.