Gather data columns into key-value pairsSource:
viewr data into a "tidy" format so that every row corresponds
to the position (and potentially rotation) of a single subject during an
observed frame and time.
A tibble in "tidy" format which is formatted to have every row
correspond to the position (and potentially rotation) of a single subject
during an observed frame and time. Subjects' names are automatically parsed
from original variable names (e.g. subject1_rotation_width extracts
"subject1" as the subject name) and stored in a
Subjects column in the
The tibble or data.frame that is fed in must have variables that
have subject names and axis names separated by underscores. Axis names must
be one of the following:
position_height. Each of these three dimensions must be present in the
data. Collectively, this means that names like
larry_position_height are acceptable, but
bird01_length are not.
library(pathviewr) ## Import the Motive example data included in the package motive_data <- read_motive_csv(system.file("extdata", "pathviewr_motive_example_data.csv", package = 'pathviewr')) ## First use relabel_viewr_axes() to rename these variables using _length, ## _width, and _height instead motive_data_relabeled <- relabel_viewr_axes(motive_data) ## Now use gather_tunnel_data() to gather colums into tidy format motive_data_gathered <- gather_tunnel_data(motive_data_relabeled) ## Column names reflect the way in which data were reformatted: names(motive_data_gathered) #>  "frame" "time_sec" "subject" #>  "position_length" "position_width" "position_height" #>  "rotation_length" "rotation_width" "rotation_height" #>  "rotation_real" "mean_marker_error"