dummify(spatstat)
dummify()所属R语言包:spatstat
Convert Data to Numeric Values by Constructing Dummy Variables
通过构建虚拟变量,将数据转换为数值
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Converts data of any kind to numeric values. A factor is expanded to a set of dummy variables.
转换数据的任何种类的数值。一个因素是扩大到一组虚拟变量。
用法----------Usage----------
dummify(x)
参数----------Arguments----------
参数:x
Vector, factor, matrix or data frame to be converted.
矢量,因子,基质或数据框来进行转换。
Details
详细信息----------Details----------
This function converts data (such as a factor) to numeric values in order that the user may calculate, for example, the mean, variance, covariance and correlation of the data.
这个函数转换的数据(如一个因素)为数字值,以便用户可以计算,例如,均值,方差协方差和相关的数据。
If x is a numeric vector or integer vector, it is returned unchanged.
如果x是一个数值向量或整数向量,它原封不动地返回。
If x is a logical vector, it is converted to a 0-1 matrix with 2 columns. The first column contains a 1 if the logical value is FALSE, and the second column contains a 1 if the logical value is TRUE.
如果x是一个逻辑向量,它被转换为一个0-1矩阵2列。第一列包含了1如果逻辑值为FALSE,第二列包含一个逻辑值1,如果是TRUE,。
If x is a complex vector, it is converted to a matrix with 2 columns, containing the real and imaginary parts.
如果x是一个复杂的矢量,它被转换为一个矩阵,与2列,包含实部和虚部。
If x is a factor, the result is a matrix of 0-1 dummy variables. The matrix has one column for each possible level of the factor. The (i,j) entry is equal to 1 when the ith factor value equals the jth level, and is equal to 0 otherwise.
如果x是一个因素,结果是一个矩阵0-1虚拟变量。该矩阵有一个列的因子为每个可能的级别。 (i,j)项是等于1当i个因子值等于j个水平时,等于,否则为0。
If x is a matrix or data frame, the appropriate conversion is applied to each column of x.
如果x是一个矩阵或数据框的,适当的转换被应用到每个列的x。
Note that, unlike model.matrix, this command converts a factor into a full set of dummy variables (one column for each level of the factor).
请注意,不像model.matrix,此命令的一个因素转换成一套完整的虚拟变量(一列每个级别的因素)。
值----------Value----------
A numeric matrix.
数字矩阵。
(作者)----------Author(s)----------
Adrian Baddeley <a href="mailto:Adrian.Baddeley@csiro.au">Adrian.Baddeley@csiro.au</a>
<a href="http://www.maths.uwa.edu.au/~adrian/">http://www.maths.uwa.edu.au/~adrian/</a>
实例----------Examples----------
chara <- sample(letters[1:3], 8, replace=TRUE)
logi <- (runif(8) < 0.3)
comp <- round(4*runif(8) + 3*runif(8) * 1i, 1)
nume <- 8:1 + 0.1
df <- data.frame(nume, chara, logi, comp)
df
dummify(df)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|