Rev 68017 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/base/man/eapply.Rd% Part of the R package, https://www.R-project.org% Copyright 1995-2011 R Core Team% Distributed under GPL 2 or later\name{eapply}\title{Apply a Function Over Values in an Environment}\usage{eapply(env, FUN, \dots, all.names = FALSE, USE.NAMES = TRUE)}\alias{eapply}\arguments{\item{env}{environment to be used.}\item{FUN}{the function to be applied, found \emph{via}\code{\link{match.fun}}.In the case of functions like \code{+}, \code{\%*\%}, etc., thefunction name must be backquoted or quoted.}\item{\dots}{optional arguments to \code{FUN}.}\item{all.names}{a logical indicating whether to apply the function toall values.}\item{USE.NAMES}{logical indicating whether the resulting list shouldhave \code{\link{names}}.}}\description{\code{eapply} applies \code{FUN} to the named values from an\code{\link{environment}} and returns the results as a list. The usercan request that all named objects are used (normally names that beginwith a dot are not). The output is not sorted and no enclosingenvironments are searched.This is a \link{primitive} function.}\value{A named (unless \code{USE.NAMES = FALSE}) list. Note that the order ofthe components is arbitrary for hashed environments.}\seealso{\code{\link{environment}}, \code{\link{lapply}}.}\examples{require(stats)env <- new.env(hash = FALSE) # so the order is fixedenv$a <- 1:10env$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 elementeapply(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)}\keyword{iteration}\keyword{environment}\keyword{list}