centers {quest} | R Documentation |
Centering and/or Standardizing Numeric Data
Description
centers
centers and/or standardized data. It is an alternative to
scale.default
that returns a data.frame rather than a numeric matrix.
Usage
centers(data, vrb.nm, center = TRUE, scale = FALSE, suffix)
Arguments
data |
data.frame of data. |
vrb.nm |
character vector of colnames from |
center |
logical vector with length 1 specifying whether grand-mean centering should be done. |
scale |
logical vector with length 1 specifying whether grand-SD scaling should be done. |
suffix |
character vector with a single element specifying the string to
append to the end of the colnames of the return object. The default depends
on the |
Details
centers
first coerces data[vrb.nm]
to a matrix in preparation
for the call to scale.default
. If the coercion results in a
non-numeric matrix (e.g., any columns in data[vrb.nm]
are character
vectors or factors), then an error is returned.
Value
data.frame of centered and/or standardized variables with colnames
specified by paste0(vrb.nm, suffix)
.
See Also
center
centers_by
center_by
scale.default
Examples
centers(data = mtcars, vrb.nm = c("disp","hp","drat","wt","qsec"))
centers(data = mtcars, vrb.nm = c("disp","hp","drat","wt","qsec"),
scale = TRUE)
centers(data = mtcars, vrb.nm = c("disp","hp","drat","wt","qsec"),
center = FALSE, scale = TRUE)
centers(data = mtcars, vrb.nm = c("disp","hp","drat","wt","qsec"),
scale = TRUE, suffix = "_std")