Recursively loads and joins trial-level data (usually additional movement data recorded outside Unity, e.g., MoCap data) to an existing tibble.
Matches files based on ppid, session_num, and trial_num, using both folder structure and filename information.
File names and file tree must follow a standard format (see below).
join_data(
trial_results,
processed_base_folder,
column_name = "processed_movement_data",
verbose = FALSE
)A data frame or tibble containing trial-level metadata with columns ppid, session_num, and trial_num.
A character string specifying the path to the base folder containing processed .csv movement files.
A character string giving the name for the new column containing nested tibbles of movement data. Default is "processed_movement_data".
Whether to save a csv of unmatched files
A tibble: the original trial_results with an added column (named by column_name) containing nested data frames of csv data, and
a column ((named by column_name + "_filepath") with the source path of this nested tibble
Files that could not be matched or read are skipped, with warnings shown.
File name must start with "T" (for trial), followed by the trial number
Files starting with "R" (for run) are actively ignored (e.g., R001_vrthreat.csv), as they refer to data not recorded trial-by-trial
Session numbers are inferred either from the folder name (.../1_2/S001/...) or directly from the session folder (.../1/S002/...).
Trial numbers are extracted from filenames like T034_*.csv.
Data loading is performed safely with purrr::possibly() to avoid stopping on corrupted files.
if (FALSE) { # \dontrun{
df_with_movement <- join_data(
trial_results = trial_results,
processed_base_folder = ".../study5/processed/vrthreat_reformatted",
column_name = "processed_movement_data"
)
} # }