R and Dropbox

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).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>