How do I get a list of built-in data sets in R?

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

Leave a Comment