14 May 2012

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

3 comments :

  1. BUT! You should never run R scripts from a source you don't trust (like J Random Person's dropbox store) without looking at them first. This script could do anything to your computer, including deleting files, sending spam emails, or acting as a DDoS Bot.

    ReplyDelete
  2. of course - I consider this to be self-evident..

    ReplyDelete
  3. Yaya... I did that too. But current mostly read data, instead of sourcing .R file. Example

    ReplyDelete