Checks if the Time data frame includes both participant-related variables and time stamp variables that appear multiple times. This may occur when data from different oTree versions, which use different variable names, are combined.
If desired, the function can merge these variables, storing the data using the newer oTree version's variable names and removing the outdated variables.
messy_time(
oTree,
combine = FALSE,
epoch_time = TRUE,
participant = TRUE,
info = FALSE
)
This function searches for multiple variables related to the time stamp
or the participant code in the $Time
data frame,
which can occur when data from both old and new oTree versions are used.
If combine = FALSE
, the function will throw an error
if such variables are found.
If combine = TRUE
, the function will not throw an error
if such variables are found.
Instead, it automatically combines the variables into new variables
and adds them to the original $Time
data frame.
This function then returns a duplicate of the original oTree list but
with the $Time
data frame modified.
The new variables are
called epoch_time_completed
and participant_code
.
A list of data frames that were created
by import_otree
.
Logical. TRUE
if all variables referring to epoch time
should be merged and/or all variables referring to participant code
should be merged in case data of several versions of oTree are used.
Logical. TRUE
if all variables referring to the time
stamp should be checked and merged. Only works if combine = TRUE
.
Logical. TRUE
if all variables referring to the
participant code should be checked and merged.
Only works if combine = TRUE
.
Logical. TRUE
if a brief information on the process should
be printed.
# Set data folder first
withr::with_dir(system.file("extdata", package = "gmoTree"), {
# Import all oTree files in this folder and its subfolders
oTree <- import_otree()
})
# Show all Time column names
print(colnames(oTree$Time))
# Run function
oTree <- messy_time(oTree, combine = TRUE)
# Show all Time column names again
print(colnames(oTree$Time))
Run the code above in your browser using DataLab