Skip to contents

Wrapper for data() and can get memory size of objects

Usage

pkg_data(pkg = "EJAM", len = 30, sortbysize = TRUE, simple = TRUE)

Arguments

pkg

a character vector giving the package(s) to look in for data sets

len

Only affects what is printed to console - specifies the number of characters to limit Title to, making it easier to see in the console.

sortbysize

if TRUE (and simple=F), sort by increasing size of object, within each package, not alpha.

simple

FALSE to get object sizes, etc., or TRUE to just get names in each package, like data(package = "EJAM")$results[, c("Package", 'Item')]

Value

If simple = TRUE, data.frame with colnames Package and Item. If simple = FALSE, data.frame with colnames Package, Item, size, Title.Short

Details

do not rely on this much - it was a quick utility. It may create and leave objects in global envt - not careful about that.

Also see functions like pkg_functions_and_data() and pkg_functions_xyz

Examples

 # see just a vector of the data object names
 data(package = "EJAM")$results[, 'Item']

 # not actually sorted within each pkg by default
 pkg_data()
 # not actually sorted by default
 pkg_data("EJAM")$Item
 ##pkg_data("MASS", simple=T)

 # sorted by size if simple=F
 ##pkg_data("datasets", simple=F)
 x <- pkg_data(simple = F)
 # sorted by size already, to see largest ones among all these pkgs:
 tail(x[, 1:3], 20)

 # sorted alphabetically within each pkg
 x[order(x$Package, x$Item), 1:2]
 # sorted alphabetically across all the pkgs
 x[order(x$Item), 1:2]

# datasets as lazyloaded objects vs. files installed with package

topic = "fips"  # or "shape" or "latlon" or "naics" or "address" etc.

# datasets / R objects
cbind(data.in.package  = sort(grep(topic, EJAM:::pkg_data()$Item, value = T)))

# files
cbind(files.in.package = sort(basename(testdata(topic, quiet = T))))