christophergandrud / repmis

Miscellaneous tools for reproducible research with R.
24 stars 9 forks source link

Allow .Rda files in source_data() #10

Closed SolomonMg closed 10 years ago

SolomonMg commented 10 years ago

Hey Christopher, I'm trying to redo all my blogposts after dropbox changed the policy re public directories and your package looks like my best bet. The following now doesn't work:

load(file(source_data("http://dl.dropboxusercontent.com/u/25710348/Blogposts/data/IL2010.Rda")))

I'd like to be able to run something like the following:

source_data("http://dl.dropboxusercontent.com/u/25710348/Blogposts/data/IL2010.Rda")

christophergandrud commented 10 years ago

Hi @solomonm

Loading Rda files with the current set up won't work because it's designed for text files. That being said, you can download your data with very few lines of code (inspired by this StackeExchange post).

If you have the new Dropbox link for the file (it should begin with https and have an /s/ in it) then you can do something like:

URL <- "https://www.dropbox.com/s/3gmur6cbfbrmzfo/IL2010.Rda"
response <- httr:GET(URL)
load(rawConnection(response$content))

(note for future reference I'll probably take down the Rda file from my dropbox in a few days)

I guess I could try adding an IF statement that uses the above code if the URL ends in .Rda or RData to repmis' source_ functions.

christophergandrud commented 10 years ago

source_data now supports .Rda files.

See 10f693440e24a15c352f8b4f86740ebad1724ed7.