Can someone please help how to get the list of built-in data sets and their dependency packages?
To get the list of available data sets in base R we can use data() but to get the list of data sets available in a package we first need to load that package then data() command shows the available data sets in that package. Also, for data sets in base R, we can use ls("package:datasets").
The default R datasets included in the base R distribution Simply check the checkbox next to the package name to load the package and gain access to the datasets. You can also click on the package name and RStudio will open a help file describing the datasets in this package.
data() function will list the datasets of all loaded packages.
There are several ways to find the included datasets in R:
1: Using data()
will give you a list of the datasets of all loaded packages (and not only the ones from the datasets
package); the datasets are ordered by package
2: Using data(package = .packages(all.available = TRUE))
will give you a list of all datasets in the available packages on your computer (i.e. also the not-loaded ones)
3: Using data(package = "packagename")
will give you the datasets of that specific package, so data(package = "plyr")
will give the datasets in the plyr
package
If you want to know in which package a dataset is located (e.g. the acme
dataset), you can do:
dat <- as.data.frame(data(package = .packages(all.available = TRUE))$results) dat[dat$Item=="acme", c(1,3,4)]
which gives:
Package Item Title 107 boot acme Monthly Excess Returns
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With