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")
a mousetrap data object created using one of the mt_import functions (see mt_example for details).
a logical expression (passed on to subset) indicating
the rows to keep. Missing values are taken as
a character string specifying which data should be used for checking the subset condition.
A mousetrap data object (see mt_example) with filtered data and trajectories.
mt_subset is helpful when trials should be removed from all analyses.
check is set to "data" meaning that the subset condition
is evaluated based on the trial data (stored in
However, it might also be of interest to only include trials based on
specific mouse-tracking measures (e.g., all trials with an
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).
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.
# 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")