Tinniam V. Ganesh Tinniam V. Ganesh - 3 months ago 27
R Question

How to read RData file with R

How can I read RData with httr? I tried a couple of things but I got error

a)

download.file(downloadURL, "temp.rData")
load("temp.rData")


b)

bin = getBinaryURL(downloadURL, ...yourOtherParams...)
writeBin(bin, "temp.rData")
load("temp.rData")


from thread Download .RData and .csv files from FTP using RCurl (or any other method)

and also using httr

c)

a=GET("https://github.com/tvganesh/yorkrData/blob/master/IPL/IPL-T20-matches/Chennai%20Super%20Kings-Deccan%20Chargers-2008-05-06.RData")
writeBin(a$content,"aa.RData")
load("aa.RData")


but I get the error

Error: bad restore file magic number (file may be corrupted) -- no data loaded
In addition: Warning message:
file ‘t.rData’ has magic number '<'
Use of save versions prior to 2 is deprecated


How can I fix this?

Thanks
Ganesh

Answer

This worked for me:

load(url("https://github.com/tvganesh/yorkrData/raw/master/IPL/IPL-T20-matches/Chennai%20Super%20Kings-Deccan%20Chargers-2008-05-06.RData"))

I get a dataframe overs from the RData-file.
The url is taken from the Download-button of the github-page to get the raw file.