Derek Corcoran Derek Corcoran - 1 month ago 28
R Question

Import RDS file from github into R Windows

I am trying to import a RDS file into RStudio in Windows, I tried following this example, which is for Rdata, and I tried both methods:

Method 1:

githubURL <- ("https://github.com/derek-corcoran-barrios/LastBat/blob/master/best2.My.Lu2.rds")
BestMyyu <- readRDS(url(githubURL))


Method 2:

githubURL <- ("https://github.com/derek-corcoran-barrios/LastBat/blob/master/best2.My.Lu2.rds")
download.file(githubURL,"best2.My.Lu2.rds")
BestMyyu <- readRDS("best2.My.Lu2.rds")


I've looked for other threads and I have not found any other example

Answer

In 2nd method you just need to add method="curl" and also change the url to point to raw (Download link on the page)

githubURL <- ("https://raw.githubusercontent.com/derek-corcoran-barrios/LastBat/master/best2.My.Lu2.rds")
download.file(githubURL,"best2.My.Lu2.rds", method="curl")
BestMyyu <- readRDS("best2.My.Lu2.rds")

If you don't have curl installed, you can get it from here

Comments