centerNumerics(rockchalk)
centerNumerics()所属R语言包:rockchalk
Find numeric columns, center them, re-name them, and join them with the original data.
寻找数字列,中心,重新命名他们,和他们一起的原始数据。
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The meanCentered regression function requires centered-inputs when calculations are predicted. For comparison with ordinary regression, it is convenient to have both centered and the original data side-by-side. This function handles that. If the input data has columns c("x1","x2","x3"), then the centered result will have columns c("x1","x2","x3","x1c","x2c","x3c"), where "c" indicates "mean-centered". If standardize=TRUE, then the result will have columns c("x1","x2","x3","x1cs","x2cs","x3cs"), where "cs" indicate "centered and scaled".
中心meanCentered回归函数需要输入时,计算预测。对于与普通回归相比,是很方便的同时具有中心的和原始数据侧由侧。这个函数处理。如果输入的数据具有列c(“×1”,“×2”,“×3”),则中心的结果将有列c(“×1”,“×2”,“×3”,“ X1C“,”X2C“,”x3c“),其中”c“表示”平均值为中心的“。如果规范= TRUE,则结果将有列c(“×1”,“×2”,“×3”,“x1cs”中,“x2cs”,“x3cs”),其中“cs的”表示“居中和缩放”。
用法----------Usage----------
centerNumerics(data, center, standardize = FALSE)
参数----------Arguments----------
参数:data
Required. data frame or matrix.
必需的。数据框或矩阵。
参数:center
Optional. If nc is NOT supplied, then all numeric columns in data will be centered (possiblly scaled). Can be specified in 2 formats. 1) Vector of column names that are to be centered, 2) Vector named elements giving values of means to be used in centering. Values must be named, as in c("x1" = 17, "x2" = 44). (possibly scaled).
可选。如果不提供NC,然后将所有数字列中的数据中心(possiblly缩放)。可以指定在2格式。 1)向量的列名的居中,2)媒介命名的元素发出要用于定心装置的值。值必须被命名,在c(“X1”= 17,“X2”= 44)。 (可能缩放)。
参数:standardize
Default FALSE. If TRUE, the variables are first mean-centered, and then divided by their standard deviations (scaled). User can supply a named vector of scale values by which to divide each variable (otherwise sd is used). Vector must have same names and length as center argument. Variables can be entered in any order (will be resorted inside function).
默认为false。如果是TRUE,变量首先意味着为中心,然后再除以它们的标准偏差(缩放)。用户可以提供一个命名为向量的刻度值,将每个变量(否则使用SD)。向量为中心的参数必须具有相同的名称和长度。变量可以输入任何命令(将使出内功能)。
值----------Value----------
A data frame with 1) All original columns 2) additional columns with centered/scaled data, variables renamed "c" or "cs" to indicate the data is centered or centered and scaled. Attributes "centers" and "scales" are created for "record keeping" on centering and scaling values.
一个数据框1)所有原列2)额外的列与中心/缩放的数据,变量改名为“C”或“CS”表示数据中心或中心和缩放。属性“中心”和“秤”创建“纪录保持”的中心和缩放值。
(作者)----------Author(s)----------
<pauljohn@ku.edu>
实例----------Examples----------
set.seed(12345)
dat <- data.frame(x1=rnorm(100,m=50), x2=rnorm(100,m=50), x3=rnorm(100,m=50), y=rnorm(100), x4=gl(2, 50, labels=c("Male","Female")))
datc1 <- centerNumerics(dat)
head(datc1)
summarize(datc1)
datc2 <- centerNumerics(dat, center=c("x1", "x2"))
head(datc2)
summarize(datc2)
attributes(datc2)
datc3 <- centerNumerics(dat, center=c("x1"=30, "x2"=40))
head(datc3)
summarize(datc3)
attributes(datc3)
datc4 <- centerNumerics(dat, center=c("x1", "x2"), standardize = TRUE)
head(datc3)
summarize(datc4)
attributes(datc4)
datc5 <- centerNumerics(dat, center=c("x1"=30, "x2"=40), standardize = c("x2" = 5, "x1" = 7))
head(datc5)
summarize(datc5)
attributes(datc5)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|