
Last chance! 50% off unlimited learning
Sale ends in
Performs a grand-mean centering of data.
center(x, ...)# S3 method for numeric
center(x, weights = NULL, robust = FALSE, verbose = TRUE, ...)
# S3 method for data.frame
center(
x,
select = NULL,
exclude = NULL,
weights = NULL,
robust = FALSE,
force = FALSE,
append = FALSE,
suffix = "_c",
verbose = TRUE,
...
)
A data frame, a (numeric or character) vector or a factor.
Currently not used.
Can be NULL
(for no weighting), or:
For data frames: a numeric vector of weights, or a character of the name of a column in the data.frame
that contains the weights.
For numeric vectors: a numeric vector of weights.
Logical, if TRUE
, centering is done by subtracting the
median from the variables. If FALSE
, variables are centered by
subtracting the mean.
Toggle warnings and messages.
Character vector of column names. If NULL
(the default), all
variables will be selected.
Character vector of column names to be excluded from selection.
Logical, if TRUE
, forces centering of factors as
well. Factors are converted to numerical values, with the lowest level
being the value 1
(unless the factor has numeric levels, which are
converted to the corresponding numeric value).
Logical, if TRUE
and x
is a data frame, standardized
variables will be added as additional columns; if FALSE
,
existing variables are overwritten.
Character value, will be appended to variable (column) names of
x
, if x
is a data frame and append = TRUE
.
The centered variables.
If centering within-clusters (instead of grand-mean centering)
is required, see demean
.
# NOT RUN {
data(iris)
head(iris$Sepal.Width)
head(center(iris$Sepal.Width))
head(center(iris))
head(center(iris, force = TRUE))
# }
Run the code above in your browser using DataLab