Calculate the time spent on one app or several apps.
apptime(
oTree,
apps = NULL,
pcode = NULL,
plabel = NULL,
group_id = NULL,
seconds = FALSE,
rounded = TRUE,
digits = 2,
sinfo = "session_code",
combine = FALSE
)
A list of data frames that were created by import_otree().
Name(s) of the app(s) for which the time should be calculated.
Character. The value of the participant.code variable if the time should only be calculated for one specified participant.
Character. The value of the participant.label variable if the time should only be calculated for one specified participant.
Integer. The value of the group_id variable if the time should only be calculated for one specified group. The group_id variable can be created with make_ids().
Logical. TRUE if the output should be in seconds instead of minutes.
Logical. TRUE if the output should be rounded.
Integer. The number of digits to which the output should be rounded. This parameter has no effect unless rounded = TRUE.
Character. "session_id" to use session ID for additional information in the data frame of single durations, "session_code" to use session codes, or NULL if no session column should be shown.
Logical. TRUE if all variables relating to epoch time should be merged, and all variables relating to participant code should be merged when data from multiple versions of oTree are used.
This function returns a list for each app containing information on the mean, the minimum, and maximum time the participants spent on the app, a data frame with information on the time each participant spent on the app, and eventually, vectors of background information on these numbers.
If the experiment's duration is only calculated for one participant, the output returns an NA (per app) if the person did not make it to the app(s).
# Use package-internal list of oTree data frames
oTree <- ioTree::oTree
# Show how much time all participants spent on app "survey"
apptime(oTree, "survey")
#> $mean_duration
#> [1] 0.28
#>
#> $min_duration
#> [1] 0.08
#>
#> $max_duration
#> [1] 1.13
#>
#> $single_durations
#> participant session duration
#> 1 46kxib6w 7bfqtokx 1.13
#> 2 iay3dhkn 7bfqtokx 0.22
#> 3 4zhzdmzo 7bfqtokx 0.15
#> 4 3ttf7yix 7bfqtokx 0.42
#> 5 2d72mfgh 7bfqtokx 0.13
#> 6 rvce7958 7bfqtokx 0.22
#> 7 lsl3vbij 7bfqtokx 0.13
#> 8 xx78b3x0 vd1h01iv 0.17
#> 9 xmxl46rm vd1h01iv 0.15
#> 10 iagvtslv t0rog7nz 0.15
#> 11 jxh15obl t0rog7nz 0.08
#> 12 a7dppel1 t0rog7nz 0.23
#> 13 wk247s9w t0rog7nz 0.73
#> 14 xkobdvuh t0rog7nz 0.40
#> 15 1l5kal0r t0rog7nz 0.13
#> 16 7l0hmpcq qyu3qg0q 0.15
#> 17 ia9rnfvc qyu3qg0q 0.15
#>
#> $messages
#> [1] "For some participants, no duration could be calculated. See list in $warnings. Did they make it to the app(s)?"
#>
#> $warnings
#> [1] "164r1hs4" "ktjz5jli" "vbhvhozv" "2scvem7a" "7wa8kk3d" "znri6myc" "ao9kqvqn"
#> [8] "d4sq7zio"
#>
# Show how much time the participant "y8rbzcju" spent on
# the app "survey"
apptime(oTree, pcode = "y8rbzcju", "survey")
#> [1] NA
# Show how much time the participants in group 4 spent on
# the app "survey"
oTree <- make_ids(oTree, gmake = TRUE,
from_var = "dictator.1.group.id_in_subsession")
apptime(oTree, group_id = 4, apps = "survey")
#> $mean_duration
#> [1] 0.13
#>
#> $min_duration
#> [1] 0.13
#>
#> $max_duration
#> [1] 0.13
#>
#> $single_durations
#> participant session duration
#> 1 lsl3vbij 7bfqtokx 0.13
#>
#> $messages
#> [1] "For some participants, no duration could be calculated. See list in $warnings. Did they make it to the app(s)?"
#>
#> $warnings
#> [1] "164r1hs4"
#>