R/standardize.R
mt_standardize.Rd
Standardize selected mouse-tracking measures across all trials or per level of one or more other variable, and store them in new variables. This function is a thin wrapper around scale_within, focussed on mouse-tracking data stored in a mousetrap data object.
mt_standardize(
data,
use = "measures",
use_variables = NULL,
within = NULL,
prefix = "z_",
center = TRUE,
scale = TRUE
)
a mousetrap data object created using one of the mt_import functions (see mt_example for details).
a character string specifying which data should be used. By
default points to the measures
data.frame created using
mt_measures.
a vector specifying which variables should be standardized. If unspecified, all variables will be standardized.
an optional character string specifying one or more variables
in data[["data"]]
. If specified, all measures will be standardized
separately for each level of the variable (or for each combination of
levels, if more than one variable is specified).
a character string that is inserted before each standardized variable. If an empty string is specified, the original variables are replaced.
argument passed on to scale.
argument passed on to scale.
A mousetrap data object (see mt_example) including the standardized measures.
mt_scale_trajectories for standardizing variables in mouse trajectory arrays.
scale_within which is called by mt_standardize
.
scale for the R base scale function.
mt_example <- mt_measures(mt_example)
# Standardize MAD and AD per subject
mt_example <- mt_standardize(mt_example,
use_variables=c("MAD", "AD"),
within="subject_nr", prefix="z_")
# Standardize MAD and AD per subject and Condition
mt_example <- mt_standardize(mt_example,
use_variables=c("MAD", "AD"),
within=c("subject_nr", "Condition"),
prefix="z_")