Learn R Programming

mousetrap (version 1.2.0)

mt_import_long: Import mouse-tracking data saved in long format.

Description

mt_import_long receives a data.frame in which mouse-tracking data are stored in long format, i.e., where one row contains the logging data (timestamp, x- and y-position etc.) at one specific point in the trial. This is, for example, the case when exporting the trajectory data from the mousetrap package using mt_reshape. From this data.frame, mt_import_long creates a mousetrap data object containing the trajectories and additional data for further processing within the mousetrap package. mt_import_long returns a list, which includes the trajectory data as an array, and all other data as a data.frame. This data structure can then be passed on to other functions within this package, such as mt_time_normalize or mt_calculate_measures. The defaults are set so that no adjustments have to be made when importing a data.frame that was created using mt_reshape.

Usage

mt_import_long(raw_data, xpos_label = "xpos", ypos_label = "ypos", timestamps_label = "timestamps", dist_label = "dist", vel_label = "vel", acc_label = "acc", mt_id_label = mt_id, mt_seq_label = "mt_seq", reset_timestamps = TRUE)

Arguments

raw_data
a data.frame in long format, containing the raw data.
xpos_label
a character string specifying the column containing the x-positions.
ypos_label
a character string specifying the column containing the y-positions.
timestamps_label
a character string specifying the column containing the timestamps.
dist_label
a character string specifying the column containing the distance traveled.
vel_label
a character string specifying the column containing the velocity.
acc_label
a character string specifying the column containing the acceleration.
mt_id_label
a character string specifying the column that provides a unique ID for every trial.
mt_seq_label
a character string specifying the column that indicactes the order of the logged coordinates within a trial. If unspecified, the coordinates will be ordered according to their timestamps.
reset_timestamps
logical indicating if the first timestamp should be subtracted from all timestamps within a trial. Default is TRUE as it is recommended for all following analyses in mousetrap.

Value

A mousetrap data object (see mt_example).

Details

The coordinates are ordered according to the values in the column provided in the mt_seq_label parameter (mt_seq by default). If the corresponding column does not exist, the coordinates will be ordered according to their timestamps (drawn from the timestamps column by default).

See Also

mt_import_mousetrap and mt_import_wide for importing mouse-tracking data from other sources.

Examples

Run this code
## Not run: 
# exp_data <- read.csv("exp_data.csv")
# data <- mt_import_long(exp_data)
# ## End(Not run)

Run the code above in your browser using DataLab