TDo
TDo

Reputation: 744

Find which package a data set is included in

Is there anyway that I can find which package a particular dataset belongs to? For example, which package does the dataset "UScereal" belong?

Thanks a lot in advance.

Upvotes: 3

Views: 2306

Answers (3)

Alex A.
Alex A.

Reputation: 5586

This is what the find() function is for.

> find("iris")
[1] "package:datasets"

> find("UScereal")
[1] "package:MASS"

If an object is in the search path, find() will tell you where it came from. See ?find for more information.

To get more information about a specific dataset, you can also use ?UScereal, which will work if UScereal is in the search path, or ??UScereal if it isn't but its parent package is installed.

To locate a dataset that isn't within an installed package, you can search for it on RDocumentation.org.

Upvotes: 13

James
James

Reputation: 66834

One way is to pull off the datasets database for all your installed packages and then query that for the data you are looking for.

x <- data(package = .packages(all.available = TRUE))$results
x[grep("UScereal",x[,"Item"]),]
                                              Package 
                                               "MASS" 
                                              LibPath 
                 "C:/Program Files/R/R-3.0.2/library" 
                                                 Item 
                                           "UScereal" 
                                                Title 
"Nutritional and Marketing Information on US Cereals"

Clearly this requires that you have installed the package. If you haven't, then you would have to search on the web for the correct package.

Upvotes: 3

konvas
konvas

Reputation: 14346

You can try ??UScerial. This will search all help files and documentation for strings matching "UScerial" and tell you which package it is from. For example on my machine I get MASS::UScereal.

(This won't work if the package is not installed on your machine, but it will work if it is installed on your machine but not loaded.)

Upvotes: 3

Related Questions