Check 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
)

Arguments

oTree

A list of data frames that were created by import_otree().

combine

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.

epoch_time

Logical. TRUE if all variables referring to the time stamp should be checked and merged. Only works if combine = TRUE.

participant

Logical. TRUE if all variables referring to the participant code should be checked and merged. Only works if combine = TRUE.

info

Logical. TRUE if a brief information on the process should be printed.

Value

This function returns an oTree list of data frames that is an exact copy of the original oTree list of data frames but - if the user wishes to do so - combines the time tamps and participant codes in the Time data frame if several variables are referring to those because of the combination of different oTree versions. The final variables are called epoch_time_completed and participant_code.

If combine = FALSE, the function only checks for the existence of several variables referring to the time stamp or the participant code and throws an error if yes.

Examples

# 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()
})
#> Warning: You have stored all_apps_wide globally but also room-specific. This function will import both of them. (Globally, the files are saved as "all_apps_wide_." Room-specific, the files are saved as "All apps - wide-" or "all_apps_wide-.") After importing the data, make sure nothing is there twice! (Advice: You may use delete_duplicate() to remove duplicate rows of all oTree data frames.

# Show all Time column names
print(colnames(oTree$Time))
#>  [1] "session_code"               "participant_id_in_session" 
#>  [3] "participant_code"           "page_index"                
#>  [5] "app_name"                   "page_name"                 
#>  [7] "epoch_time"                 "round_number"              
#>  [9] "timeout_happened"           "is_wait_page"              
#> [11] "epoch_time_completed"       "session_id"                
#> [13] "participant__id_in_session" "participant__code"         
#> [15] "time_stamp"                 "seconds_on_page"           
#> [17] "subsession_pk"              "auto_submitted"            

# Run function
oTree <- messy_time(oTree, combine = TRUE)

# Show all Time column names again
print(colnames(oTree$Time))
#>  [1] "session_code"               "participant_id_in_session" 
#>  [3] "participant_code"           "page_index"                
#>  [5] "app_name"                   "page_name"                 
#>  [7] "round_number"               "timeout_happened"          
#>  [9] "is_wait_page"               "epoch_time_completed"      
#> [11] "session_id"                 "participant__id_in_session"
#> [13] "seconds_on_page"            "subsession_pk"             
#> [15] "auto_submitted"