eapply
Apply a Function Over Values in an Environment

Description

Applies a function to all objects in an environment and returns the results in a list.

Usage

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

Arguments

env the environment to which FUN is applied.
FUN the function to apply to the objects in env. Alternatively, it can be a character string giving the name of the function.
... other arguments to FUN, if any. They can be given with names.
all.names a logical flag. If TRUE, all names in the variable in env are applied with FUN. If FALSE (the default), all names variables except the hidden variable(that is, names that begin with dot) are applied.
USE.NAMES a logical flag. If TRUE (the default), names are included in the returned list.
Value
returns a list with or without names. Each component of the list is the result of FUN, applied to each object in env.
See Also
apply, lapply, environment,
Examples
newEnv <- new.env()
assign("x", c(1:10), envir = newEnv)  # same as: newEnv$x <- c(1:10)
assign("y", c(4, 5), envir = newEnv)  # same as: newEnv$y <- c(4, 5)
eapply(newEnv, sin)
eapply(newEnv, sum)
eapply(newEnv, f<-function(x,y) x+y, y = 2)

newEnv$.Matrix <- matrix(1:12, nrow = 3) # create a hidden variable.

# By default, the hidden variables are not applied with sum. eapply(newEnv, sum)

# .Matrix is also applied with sum. eapply(newEnv, sum, all.names = TRUE)

# No names in returned list eapply(newEnv, sum, all.names = TRUE, USE.NAMES = FALSE)

Package base version 6.1.4-13
Package Index