expand.grid(base)
expand.grid()所属R语言包:base
Create a Data Frame from All Combinations of Factors
创建一个从所有的因素组合的数据框
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Create a data frame from all combinations of the supplied vectors or factors. See the description of the return value for precise details of the way this is done.
所有提供的向量或因素的组合创建一个数据框。看到这样做的方法,精确的细节描述返回值。
用法----------Usage----------
expand.grid(..., KEEP.OUT.ATTRS = TRUE, stringsAsFactors = TRUE)
参数----------Arguments----------
参数:...
vectors, factors or a list containing these.
向量的因素或含有这些列表。
参数:KEEP.OUT.ATTRS
a logical indicating the "out.attrs" attribute (see below) should be computed and returned.
逻辑表示"out.attrs"属性(见下文)应计算并返回。
参数:stringsAsFactors
logical specifying if character vectors are converted to factors.
逻辑指定字符向量转换因素。
值----------Value----------
A data frame containing one row for each combination of the supplied factors. The first factors vary fastest. The columns are labelled by the factors if these are supplied as named arguments or named components of a list. The row names are "automatic".
一个数据框包含一排,每个组合所提供的因素。第一个因素变化最快的。如果这些命名参数或命名的组件列表提供的列标记的因素。该行的名称是“自动”。
Attribute "out.attrs" is a list which gives the dimension and dimnames for use by predict methods.
属性"out.attrs"是一个名单,使维和dimnames由predict方法使用。
注意----------Note----------
Conversion to a factor is done with levels in the order they occur in the character vectors (and not alphabetically, as is most common when converting to factors).
转换的一个因素是他们中的特征向量(和不按字母顺序排列,是最常见的转换因素时)发生的顺序水平。
参考文献----------References----------
Statistical Models in S. Wadsworth & Brooks/Cole.
参见----------See Also----------
combn (package utils) for the generation of all combinations of n elements, taken m at a time.
combn(包utils)生成所有n个元素,采取在一段时间的米组合。
举例----------Examples----------
require(utils)
expand.grid(height = seq(60, 80, 5), weight = seq(100, 300, 50),
sex = c("Male","Female"))
x <- seq(0,10, length.out=100)
y <- seq(-1,1, length.out=20)
d1 <- expand.grid(x=x, y=y)
d2 <- expand.grid(x=x, y=y, KEEP.OUT.ATTRS = FALSE)
object.size(d1) - object.size(d2)
##-> 5992 or 8832 (on 32- / 64-bit platform)[# - > 5992或8832(32 - / 64位平台)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|