scale_within: Scale and center variables within the levels of another variable.
Description
scale_within centers and/or scales variables in a data.frame (using
scale) depending on the levels of one or more other variables By
default, variables are standardized (i.e., centered and scaled). A typical
application is the within-subject standardization of variables in a repeated
measures design.
Usage
scale_within(data, variables = NULL, within = NULL, prefix = "",
center = TRUE, scale = TRUE)
a character string (or vector) specifying one or more
variables that scale is applied to. If unspecified,
scale_within will be applied to all variables in data.
within
a character string specifying the name of one or more variables
in data. For each of the levels of this variable (or for each
combination of levels, if more than one variable is specified),
scale is applie
prefix
a character string that is inserted before each scaled
variable. By default (empty string) the original variables are replaced.