scale_within | R Documentation |
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.
scale_within(
data,
variables = NULL,
within = NULL,
prefix = "",
center = TRUE,
scale = TRUE
)
data |
a data.frame. |
variables |
a character string (or vector) specifying one or more
variables that scale is applied to. If unspecified,
|
within |
an optional character string specifying the name of one or more
variables in |
prefix |
a character string that is inserted before each scaled variable. By default (empty string) the original variables are replaced. |
center |
argument passed on to scale. |
scale |
argument passed on to scale. |
The original data.frame including the centered and / or scaled variables.
Pascal J. Kieslich
Felix Henninger
scale for the R base scale function.
mt_standardize for standardizing measures in a mousetrap data object.
ChickWeight_scaled <- scale_within(
ChickWeight, variables="weight",
within="Chick", prefix="z_")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.