Learn R Programming

sfsmisc (version 1.0-24)

str_data: Overview on All Datasets in an R Package

Description

Provide an overview over all datasets available by data() in a (list of) given Rpackages.

Usage

str_data(pkgs, filterFUN, ...)

Arguments

pkgs
character vector of names of Rpackages.
filterFUN
optionally a logical function for filtering the Robjects.
...
potentical further arguments to be passed to str; str(utils:::str.default) gives useful list.

Value

  • invisibly (see invisible) a list with named components matching the pkgs argument. Each of these components is a named list with one entry per data(.) argument name. Each entry is a character vector of the names of all objects, typically only one.

    The side effect is, as with str(), to print everything (via cat) to the console.

See Also

str, data.

Examples

Run this code
str_data("cluster")

str_data("datasets", max=0, give.attr = FALSE)

## Filtering (and return value)
dfl <- str_data("datasets", filterFUN=is.data.frame)
df.d <- dfl$datasets
## work around bug in R < 2.14.1 (?) {for *some* setups only}:
str(df.d <- df.d[sapply(df.d, is.character)])
## dim() of all those data frames:
t(sapply(unlist(df.d), function(.) dim(get(.))))

### Data sets in all attached packages but "datasets" (and stubs):
s <- search()
(Apkgs <- sub("^package:", '', s[grep("^package:", s)]))
str_data(Apkgs[!Apkgs %in% c("datasets", "stats", "base")])

Run the code above in your browser using DataLab