| mt_aggregate_per_subject | R Documentation | 
mt_aggregate_per_subject can be used for aggregating mouse-tracking
measures (or trajectories) per condition separately for each subject. One or
more condition variables can be specified using use2_variables.
Aggregation will be performed separately for each level of the condition
variables. mt_aggregate_per_subject is a wrapper function for
mt_reshape.
mt_aggregate_per_subject(
  data,
  use = "measures",
  use_variables = NULL,
  use2 = "data",
  use2_variables = NULL,
  subject_id,
  trajectories_long = TRUE,
  ...
)
data | 
 a mousetrap data object created using one of the mt_import
functions (see mt_example for details). Alternatively, a trajectory
array can be provided directly (in this case   | 
use | 
 a character string specifying which dataset should be aggregated.
The corresponding data are selected from   | 
use_variables | 
 a character vector specifying the mouse-tracking
variables to aggregate. If a data.frame with mouse-tracking measures is
provided as   | 
use2 | 
 a character string specifying where the data containing the
condition information can be found. Defaults to "data" as
  | 
use2_variables | 
 a character string (or vector) specifying the variables
(in   | 
subject_id | 
 a character string specifying which column contains the subject identifier.  | 
trajectories_long | 
 logical indicating if the reshaped trajectories
should be returned in long or wide format. If   | 
... | 
 additional arguments passed on to mt_reshape (such as
  | 
A data.frame containing the aggregated data.
Pascal J. Kieslich
Felix Henninger
mt_aggregate for aggregating mouse-tracking measures and trajectories per condition.
summarize_at for aggregating data using the dplyr
package.
# Time-normalize trajectories
mt_example <- mt_time_normalize(mt_example)
# Aggregate time-normalized trajectories per condition
# separately per subject
average_trajectories <- mt_aggregate_per_subject(
  mt_example,
  use="tn_trajectories",
  use2_variables="Condition",
  subject_id="subject_nr"
)
# Calculate mouse-tracking measures
mt_example <- mt_measures(mt_example)
# Aggregate measures per condition
# separately per subject
average_measures <- mt_aggregate_per_subject(
  mt_example,
  use="measures",
  use_variables=c("MAD", "AD"),
  use2_variables="Condition",
  subject_id="subject_nr"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.