simApply(simFrame)
simApply()所属R语言包:simFrame
Apply a function to subsets
应用功能的子集
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Generic functions for applying a function to subsets of a data set.
应用一个函数,一个数据集的子集的通用函数。
用法----------Usage----------
simApply(x, design, fun, ...)
simSapply(x, design, fun, ..., simplify = TRUE)
参数----------Arguments----------
参数:x
the data.frame to be subsetted.
data.frame子集。
参数:design
a character, logical or numeric vector specifying the variables (columns) used for subsetting.
逻辑或数字字符,矢量,指定用于子集的变量(列)。
参数:fun
a function to be applied to the subsets.
要施加到子集的一个函数。
参数:simplify
a logical indicating whether the results should be simplified to a vector or matrix (if possible).
逻辑的结果是否应该被简化为一个向量或矩阵(如果可能的话)。
参数:...
additional arguments to be passed to fun.
额外的参数传递给fun。
值----------Value----------
For simApply a data.frame.
对于simApplydata.frame的。
For simSapply, a list, vector or matrix (see sapply).
对于simSapply,列表,向量或矩阵(见sapply)。
功能simApply方法----------Methods for function simApply----------
x = "data.frame", design = "BasicVector", fun = "function" apply
x = "data.frame", design = "BasicVector", fun = "function"申请
x = "data.frame", design = "Strata", fun = "function" apply a
x = "data.frame", design = "Strata", fun = "function"应用
功能simSapply方法----------Methods for function simSapply----------
x = "data.frame", design = "BasicVector", fun = "function" apply
x = "data.frame", design = "BasicVector", fun = "function"申请
x = "data.frame", design = "Strata", fun = "function" apply a
x = "data.frame", design = "Strata", fun = "function"应用
(作者)----------Author(s)----------
Andreas Alfons
参见----------See Also----------
sapply
sapply
实例----------Examples----------
data(eusilcP)
eusilcP <- eusilcP[, c("region", "gender", "eqIncome")]
## returns data.frame[#返回数据框]
simApply(eusilcP, c("region", "gender"),
function(x) median(x$eqIncome))
## returns vector[#返回向量]
simSapply(eusilcP, c("region", "gender"),
function(x) median(x$eqIncome))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|