Learn R Programming

mousetrap (version 2.0.0)

mt_standardize: Standardize mouse-tracking measures per level of other variables.

Description

Standardize selected mouse-tracking measures 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.

Usage

mt_standardize(data, use = "measures", use_variables = NULL, within = "subject_nr", prefix = "z_", center = TRUE, scale = TRUE)

Arguments

data
a mousetrap data object created using one of the mt_import functions (see mt_example for details).
use
a character string specifying which data should be used. By default points to the measures data.frame created using mt_measures.
use_variables
a vector specifying which variables should be standardized. If unspecified, all variables will be standardized.
within
a character string specifying one or more variables in data[["data"]]. 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). By default, points to the subject identifier used in OpenSesame ("subject_nr").
prefix
a character string that is inserted before each standardized variable. If an empty string is specified, the original variables are replaced.
center
argument passed on to scale.
scale
argument passed on to scale.

Value

A mousetrap data object (see mt_example) including the standardized measures.

See Also

scale_within which is called by mt_standardize.

scale for the R base scale function.

Examples

Run this code
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_")

Run the code above in your browser using DataLab