Sapply

0th

Percentile

A Dimension Preserving Variant of "sapply" and "lapply"

Sapply is equivalent to sapply, except that it preserves the dimension and dimension names of the argument X. It also preserves the dimension of results of the function FUN. It is intended for application to results e.g. of a call to by. Lapply is an analog to lapply insofar as it does not try to simplify the resulting list of results of FUN.

Keywords
misc, utilities
Usage
Sapply(X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE)
Lapply(X, FUN, ...)
Arguments
X

a vector or list appropriate to a call to sapply.

FUN

a function.

...

optional arguments to FUN.

simplify

a logical value; should the result be simplified to a vector or matrix if possible?

USE.NAMES

logical; if TRUE and if X is character, use X as names for the result unless it had names already.

Value

If FUN returns a scalar, then the result has the same dimension as X, otherwise the dimension of the result is enhanced relative to X.

• Lapply
• Sapply
Examples
# NOT RUN {
berktest1 <- By(~Dept+Gender,
data=berkeley)
berktest2 <- By(~Dept,
data=berkeley)

sapply(berktest1,coef)
Sapply(berktest1,coef)

sapply(berktest1,function(x)drop(coef(summary(x))))
Sapply(berktest1,function(x)drop(coef(summary(x))))

sapply(berktest2,coef)
Sapply(berktest2,coef)
sapply(berktest2,function(x)coef(summary(x)))
Sapply(berktest2,function(x)coef(summary(x)))
# }

Documentation reproduced from package memisc, version 0.99.27.3, License: GPL-2

Community examples

wenfangcai601@gmail.com at Oct 25, 2017 memisc v0.99.14.3