Can I download a data package without installing the package?

The ISLR package has a dataset called Default .

I want to use this dataset, but the ISLR package is not installed on my machine.

 data(Default) # Warning message: # In data(Default) : data set 'Default' not found library(ISLR) # Error in library(ISLR) : there is no package called 'ISLR' 

Since I will probably never use it again, I do not want to install the package. I was thinking of reading it from the Internet, but not on the linked web page from the package description.

In general, is there a way to download a dataset from a package without installing the package?

+5
source share
2 answers

You can do this from R:

 download.file("http://cran.r-project.org/src/contrib/ISLR_1.0.tar.gz", dest="ISLR.tar.gz") untar("ISLR.tar.gz",files="ISLR/data/Default.rda") L <- load("ISLR/data/Default.rda") summary(Default) 

If you want to keep a copy of the data file:

 file.copy("ISLR/data/Default.rda",".") 

Cleaning:

 unlink(c("ISLR.tar.gz","ISLR"),recursive=TRUE) 

I'm not sure if you might need to load tarball - in principle, you could run untar() directly on a network connection, but I don’t think the underlying mechanism can actually extract the file without loading the entire tarball somewhere on your machine.

+9
source

You said: "Since I will probably never use it again, I do not want to install the package." If the fact that you will never use it again is your main concern, then maybe this solution is not quite what you want, but it is probably a simple solution:

  • Install the package with install.packages() .
  • Extract and save the desired data set.
  • Remove the package using remove.packages() .

So, the end result is what you want in three simple steps, although the process involves installing a package that you hoped to avoid. But you do not receive a package on your system that you do not need, so the end result is the same as what you want.

0
source

Source: https://habr.com/ru/post/1201377/


All Articles