简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM