Sunday, September 20, 2015

Source R-Script from Dropbox

A quick tip on how to source R-scripts from a Dropbox-account:

(1) Upload the script..

(2) Get link with the "get link" option. The link should look like "https://www.dropbox.com/s/XXXXXX/yourscript.R"..

(3) Grab this part "XXXXXX/yourscript.R" and paste it to "http://dl.dropbox.com/s/"..





(4) the final URL that can be sourced:
source("http://dl.dropbox.com/s/XXXXXX/yourscript.R")
..an example with this script stored at my Dropbox account:
source("http://dl.dropbox.com/s/c18lcwnnrodsevt/test_dropbox_source.R")

EDIT, March 2013:
This method is not working anymore. You can use the following approach instead:

library(RCurl)
setwd(tempdir())

destfile = "test.txt"
x = getBinaryURL("https://dl.dropbox.com/u/68286640/test_dropbox_source.R", followlocation = TRUE, ssl.verifypeer = FALSE)
writeBin(x, destfile, useBytes = TRUE)
source(paste(tempdir(), "/test.txt", sep = ""))

# remove files from tempdir:
unlink(dir())

No comments:

Post a Comment