Skip to contents

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

Usage

datapack(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.

Examples

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

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

 # sorted by size if simple=F
 ##datapack("datasets", simple=F)
 x <- datapack(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:::datapack()$Item, value = T)))

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