eapply: Apply a Function Over Values in an Environment

Description Usage Arguments Value See Also Examples

Description

eapply applies FUN to the named values from an environment and returns the results as a list. The user can request that all named objects are used (normally names that begin with a dot are not). The output is not sorted and no enclosing environments are searched.

This is a primitive function.

Usage

1
eapply(env, FUN, ..., all.names = FALSE, USE.NAMES = TRUE)

Arguments

env

environment to be used.

FUN

the function to be applied, found via match.fun. In the case of functions like +, %*%, etc., the function name must be backquoted or quoted.

...

optional arguments to FUN.

all.names

a logical indicating whether to apply the function to all values.

USE.NAMES

logical indicating whether the resulting list should have names.

Value

A named (unless USE.NAMES = FALSE) list. Note that the order of the components is arbitrary for hashed environments.

See Also

environment, lapply.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
require(stats)

env <- new.env(hash = FALSE) # so the order is fixed
env$a <- 1:10
env$beta <- exp(-3:3)
env$logic <- c(TRUE, FALSE, FALSE, TRUE)
# what have we there?
utils::ls.str(env)

# compute the mean for each list element
       eapply(env, mean)
unlist(eapply(env, mean, USE.NAMES = FALSE))

# median and quartiles for each element (making use of "..." passing):
eapply(env, quantile, probs = 1:3/4)
eapply(env, quantile)

robertzk/monadicbase documentation built on May 27, 2019, 10:35 a.m.