mt_import_mousetrap accepts a data.frame of (merged) raw data from a
mouse-tracking experiment implemented in OpenSesame using the
mousetrap plugin. From
this data.frame, mt_import_mousetrap creates a mousetrap data object
containing the trajectories and additional data for further processing within
the mousetrap package. Specifically, it returns a list that includes the
trajectory data as an array (called trajectories), and all other data
as a data.frame (called data). This data structure can then be passed
on to other functions within this package (see mousetrap for an
overview).
mt_import_mousetrap(raw_data, xpos_label = "xpos", ypos_label = "ypos", timestamps_label = "timestamps", mt_id_label = NULL, split = ",", duplicates = "remove_first", reset_timestamps = TRUE, verbose = FALSE, show_progress = NULL)TRUE as it
is recommended for all following analyses in mousetrap.verbose instead.raw_data need to be
provided. All other arguments have sensible defaults.If the relevant timestamps, x-positions, and y-positions are each stored in
one variable, a character string specifying (parts of) the respective column
name needs to be provided. In this case, the column names are extracted using
grep to find the column that starts with the respective character
string (in OpenSesame these will typically contain the name of the item that
was used to record them, such as xpos_get_response). This means that
the exact column names do not have to be provided - as long as only one
column starts with the respective character string (otherwise, the exact
column names have to be provided).
If several variables contain the timestamps, x-positions, and y-positions
within a trial (e.g., xpos_part1 and xpos_part2), a vector of
the exact column names has to be provided (e.g.,
xpos_label=c("xpos_part1","xpos_part2")). mt_import_mousetrap
will then merge all raw data in the order with which the variable labels have
been specified. If one variable contains NAs or an empty string in a trial,
these cases will be ignored (this covers the special case that, e.g.,
xpos_part2 is only relevant for some trials and contains NAs in the
other trials).
duplicates allows for different options to handle duplicate timestamps
within a trial:
remove_first: First timestamp and
corresponding x-/y-positions are removed (the default).
remove_last: Last timestamp and corresponding x-/y-positions are
removed. ignore: Duplicates are kept. readbulk library
for reading and combining raw data files that were collected with
OpenSesame.mt_import_wide and mt_import_long for importing mouse-tracking data from other sources.
mt_data <- mt_import_mousetrap(mt_example_raw)
Run the code above in your browser using DataLab