Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import RDS file from github into R Windows

Tags:

import

r

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

like image 569
Derek Corcoran Avatar asked Oct 19 '16 18:10

Derek Corcoran


People also ask

How do I load data from github into R?

The most direct way to get data from Github to your computer/ into R, is to download the repository. That is, click the big green button: The big, green button saying “Clone or download”, click it and choose “download zip”. Of course, for those using Git and Github, it would be appropriate to clone the repository.

How do I read an RDS file in Rstudio?

Reading from a R data file R has its own data file format–it's usually saved using the . rds extension. To read a R data file, invoke the readRDS() function.

What is a .RDS file in R?

R also has two native data formats—Rdata (sometimes shortened to Rda) and Rds. These formats are used when R objects are saved for later use. Rdata is used to save multiple R objects, while Rds is used to save a single R object. See below for instructions on how to read and load data into R from both file extensions.


1 Answers

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

like image 140
Ivan Avatar answered Sep 19 '22 07:09

Ivan