Return a subset of the mousetrap data including only the trial data and corresponding trajectories that meet the conditions specified in the arguments.

mt_subset(data, subset, check = "data")

Arguments

data

a mousetrap data object created using one of the mt_import functions (see mt_example for details).

subset

a logical expression (passed on to subset) indicating the rows to keep. Missing values are taken as FALSE.

check

a character string specifying which data should be used for checking the subset condition.

Value

A mousetrap data object (see mt_example) with filtered data and trajectories.

Details

mt_subset is helpful when trials should be removed from all analyses. By default, check is set to "data" meaning that the subset condition is evaluated based on the trial data (stored in data[["data"]]). However, it might also be of interest to only include trials based on specific mouse-tracking measures (e.g., all trials with an MAD smaller than 200). In this case, check needs to be set to the respective name of the data.frame (e.g., "measures").

Note that if specific trials should be removed from all analyses based on a condition known a priori (e.g., practice trials), it is more efficient to use the subset function on the raw data before importing the trajectories using one of the mt_import functions (such as mt_import_mousetrap).

Besides, if trials should only be removed from some analyses or for specific plots, note that other mousetrap functions (e.g., mt_reshape, mt_aggregate, and mt_plot) also allow for subsetting.

See also

subset for the R base subset function for vectors, matrices, or data.frames.

mt_reshape for information about the subset argument in various other mousetrap functions.

Author

Pascal J. Kieslich

Felix Henninger

Examples

# Subset based on trial data
mt_example_atypical <- mt_subset(mt_example, Condition=="Atypical")

# Subset based on mouse-tracking measure (MAD)
mt_example <- mt_measures(mt_example)
mt_example_mad_sub <- mt_subset(mt_example, MAD<400, check="measures")