rawr_ls: List utilities

rawr_lsR Documentation

List utilities

Description

These functions begin with ls and list different things. lss is an "improved" ls which gives more details of objects in the workspace such as type, size, and dimensions; lsp lists package contents, i.e., exported and/or non exported objects, methods, lazy data, etc.; and lsf lists package files. See details and examples.

Usage

lss(
  pos = 1L,
  pattern,
  by = NULL,
  all.names = FALSE,
  decreasing = TRUE,
  n = Inf
)

lsf(package, file = "DESCRIPTION")

lsp(package, what, pattern)

Arguments

pos

argument specifying the environment as a position in search list or a "list-like" object such as a data frame or list of objects

pattern

optional regex; for lss only names matching pattern are returned; glob2rx can be used to convert wildcard patterns to regular expressions; for lsp a text pattern or regular expression passed to grep to filter the results

by

variable to order output ("type", "size" (default), "sizef", "nrow", or "ncol")

all.names

logical; if TRUE, all object names are returned; if FALSE, names which begin with a . are omitted

decreasing

logical; if TRUE, displays output in decreasing order

n

number of objects to displace if head is TRUE

package

package name, as a name or literal character string

file

file to return as a character string; usual options are "DESCRIPTION", "NEWS", "INDEX", "NAMESPACE"; partial matching is supported and case is ignored

what

what to get; "all" is default which returns all exported and non exported functions in package; see details for more

Details

lsf prints package files (e.g., DESCRIPTION, NEWS, INDEX, NAMESPACE, etc.) to console and returns (invisibly) the files parsed for easier use.

lsp is a helper function to list exported (?"::") and non exported (?":::") functions (and other features from a package's NAMESPACE file).

Note that base and older packages do not have a NAMESPACE file in which case, for base packages, lsp returns ls(.BaseNamespaceEnv, all.names = TRUE), and throws an error otherwise.

Possible values for what are "all" (default), NULL, "exports", "imports", "dynlibs", "lazydata", "path", "S3methods", "spec", and others depending on the package.

lsp(packagename, "?") to see options for a specific package.

lsp(packagename, NULL) to return all information in a list.

Value

lss returns a data frame with each object from the workspace with type, object size, and dimensions for each. lsf (invisibly) returns the contents of file after being printed to the console. lsp returns a vector of character strings.

See Also

ls; search; rawr_parse

Examples

## lss(): use like ls()
lss()
a <- rnorm(100000)
b <- matrix(1, 1000, 100)
lss()

## lsf(): these are equivalent ways to use
lsf(rawr)
lsf(rawr, 'DESCRIPTION')
lsf('rawr', 'des')

## lsp: see the contents of a package
lsp(rawr)

## return all one- or two-character functions from base package
lsp(base, pat = '^.{1,2}$')

## for "what" options
lsp('rawr', '?')

## library path
lsp('rawr', 'path')
system.file(package = 'rawr')

## to return everything
lsp('rawr')

## data sets
lsp('rawr', 'lazydata')


raredd/rawr documentation built on March 4, 2024, 1:36 a.m.