找回密码
 注册
查看: 9840|回复: 0

R语言:split()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 21:11:20 | 显示全部楼层 |阅读模式
split(base)
split()所属R语言包:base

                                        Divide into Groups and Reassemble
                                         分组和重组

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

split divides the data in the vector x into the groups defined by f.  The replacement forms replace values corresponding to such a division.  unsplit reverses the effect of split.
split分为在矢量到x定义组f数据。更换的形式取代这种分工对应的值。 unsplitsplit反转效果。


用法----------Usage----------


split(x, f, drop = FALSE, ...)
split(x, f, drop = FALSE, ...) <- value
unsplit(value, f, drop = FALSE)



参数----------Arguments----------

参数:x
vector or data frame containing values to be divided into groups.
向量或数据框包含的值被分为若干组。


参数:f
a "factor" in the sense that as.factor(f) defines the grouping, or a list of such factors in which case their interaction is used for the grouping.
“因素”在这个意义上,as.factor(f)定义分组,或分组使用在这种情况下,他们的互动等因素的列表。


参数:drop
logical indicating if levels that do not occur should be dropped (if f is a factor or a list).
逻辑表示如果没有发生的水平,应该被丢弃(f如果是factor或列表)。


参数:value
a list of vectors or data frames compatible with a splitting of x. Recycling applies if the lengths do not match.
与分裂的x兼容的向量或数据框列表。回收适用,如果长度不匹配。


参数:...
further potential arguments passed to methods.
进一步潜在的参数传递方法。


Details

详情----------Details----------

split and split<- are generic functions with default and data.frame methods. The data frame method can also be used to split a matrix into a list of matrices, and the replacement form likewise, provided they are invoked explicitly.
split和split<-默认data.frame方法的通用功能。数据框的方法也可以被分成一个矩阵,矩阵列表,更换同样的形式,提供了显式调用。

unsplit works with lists of vectors or data frames (assumed to have compatible structure, as if created by split). It puts elements or rows back in the positions given by f. In the data frame case, row names are obtained by unsplitting the row name vectors from the elements of value.
unsplit(假设有兼容的结构,如果创建split)与向量或数据框的列表。它把元素或行在f的位置。在数据框的情况下,行名行名称向量unsplitting从value的元素。

f is recycled as necessary and if the length of x is not a multiple of the length of f a warning is printed.
,f回收作为必要的,如果x长度不f一个警告被打印的长度的倍数。

Any missing values in f are dropped together with the corresponding values of x.
失踪任何f的值都将被丢弃在一起x的相应值。


值----------Value----------

The value returned from split is a list of vectors containing the values for the groups.  The components of the list are named by the levels of f (after converting to a factor, or if already a factor and drop=TRUE, dropping unused levels).
split返回的值是一个组值的向量列表。列表的组件被命名为f水平(转换后的一个因素,或已经是一个因素和drop=TRUE,删除未使用的水平)。

The replacement forms return their right hand side.  unsplit returns a vector or data frame for which split(x, f) equals value
更换的形式返回其右侧。 unsplit返回一个向量或数据框为split(x, f)的平等value的


参考文献----------References----------

The New S Language. Wadsworth &amp; Brooks/Cole.

参见----------See Also----------

cut to categorize numeric values.
cut数值分类。

strsplit to split strings.
strsplit来分割字符串。


举例----------Examples----------


require(stats); require(graphics)
n <- 10; nn <- 100
g <- factor(round(n * runif(n * nn)))
x <- rnorm(n * nn) + sqrt(as.numeric(g))
xg <- split(x, g)
boxplot(xg, col = "lavender", notch = TRUE, varwidth = TRUE)
sapply(xg, length)
sapply(xg, mean)

### Calculate 'z-scores' by group (standardize to mean zero, variance one)[##计算的Z-分数“组(标准化意味着零,方差1)]
z <- unsplit(lapply(split(x, g), scale), g)

# or[或]

zz <- x
split(zz, g) <- lapply(split(x, g), scale)

# and check that the within-group std dev is indeed one[检查组内标准差,的确是一个]
tapply(z, g, sd)
tapply(zz, g, sd)


### data frame variation[数据框的变化#]

## Notice that assignment form is not used since a variable is being added[#注意,不使用转让的形式,自变量被添加]

g <- airquality$Month
l <- split(airquality, g)
l <- lapply(l, transform, Oz.Z = scale(Ozone))
aq2 <- unsplit(l, g)
head(aq2)
with(aq2, tapply(Oz.Z,  Month, sd, na.rm=TRUE))


### Split a matrix into a list by columns[#分割成一个list列矩阵]
ma <- cbind(x = 1:10, y = (-4:5)^2)
split(ma, col(ma))

split(1:10, 1:2)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-23 22:30 , Processed in 0.029490 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表