tapplySimpl(sfsmisc)
tapplySimpl()所属R语言包:sfsmisc
More simplification in tapply() result
简化tapply()的结果
译者:生物统计家园网 机器人LoveR
描述----------Description----------
For the case of more than two categories or indices (in INDEX), traditional tapply(*, simplify = TRUE) still returns a list when an array may seem more useful and natural. This is provided by tapplySimpl() if the function FUN() is defined such as to return a vector of the same length in all cases.
的情况下,两个以上的类别或指数(在INDEX),传统的tapply(*, simplify = TRUE)返回一个列表,当数组似乎更多有用的和自然的。这是由tapplySimpl(),如果函数FUN()被定义,如在所有的情况下具有相同的长度返回一个矢量。
用法----------Usage----------
tapplySimpl(X, INDEX, FUN, ...)
参数----------Arguments----------
参数:X
an atomic object, typically a vector. All these arguments are as in tapply() and are passed to tapply(..).
一个原子对象,通常是一个矢量。所有这些论点是在tapply()和传递给tapply(..)。
参数:INDEX
list of (typically more than one) factors, each of same length as X.
列表中(通常为一个以上的)因素,每一个相同的长度X。
参数:FUN
the function to be applied. For the result to be simplifiable, FUN() must return a vector of always the same length.
该函数被应用。对于的结果是simplifiable的,FUN()必须返回一个总是具有相同的长度的矢量。
参数:...
optional arguments to FUN.
可选参数到FUN。
值----------Value----------
If the above conditions are satisfied, the list returned from r <- tapply(X, INDEX, FUN, ...) is simplified into an array of rank 1 + \#\{indices\}, i.e., 1+length(INDEX); otherwise, tapplySimpl() returns the list r, i.e., the same as tapply().
如果满足上述条件,返回的列表r <- tapply(X, INDEX, FUN, ...)的array排名1 + \#\{indices\},即简化为,1+length(INDEX),否则,tapplySimpl()返回列表r,即一样tapply()的。
(作者)----------Author(s)----------
Martin Maechler, 14 Jun 1993 (for S-plus).
参见----------See Also----------
tapply(*, simplify=TRUE).
tapply(*, simplify=TRUE)。
实例----------Examples----------
## Using tapply() would give a list (with dim() of a matrix);[#使用tapply()将一个列表(DIM()的矩阵);]
## here we get 3-array:[#在这里我们得到3阵列:]
data(esoph)
with(esoph, {
mima <<- tapplySimpl(ncases/ncontrols, list(agegp, alcgp), range)
stopifnot(dim(mima) == c(2, nlevels(agegp), nlevels(alcgp)))
})
aperm(mima)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|