Skip to contents

Calculate the time spent on one app or several apps.

Usage

apptime(
  oTree,
  apps = NULL,
  pcode = NULL,
  plabel = NULL,
  group_id = NULL,
  seconds = FALSE,
  rounded = TRUE,
  digits = 2,
  sinfo = "session_code",
  combine = FALSE
)

Arguments

oTree

A list of data frames that were created by import_otree

apps

Character. Name(s) of the app(s) for which the time should be calculated.

pcode

Character. The value of the participant.code variable if the time should only be calculated for one specified participant.

plabel

Character. The value of the participant.label variable if the time should only be calculated for one specified participant.

group_id

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.

seconds

Logical. TRUE if the output should be in seconds instead of minutes.

rounded

Logical. TRUE if the output should be rounded.

digits

Integer. The number of digits to which the output should be rounded. This parameter has no effect unless rounded = TRUE.

sinfo

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.

combine

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.

Value

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 relevant 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).

Examples

# Use package-internal list of oTree data frames
oTree <- gmoTree::oTree

# Show how much time all participants spent on app "survey"
apptime(oTree, apps = "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."
#> 
#> $warnings
#> [1] "164r1hs4" "ktjz5jli" "vbhvhozv" "2scvem7a" "7wa8kk3d" "znri6myc" "ao9kqvqn"
#> [8] "d4sq7zio"
#> 

# Show how much time the participant "a7dppel1" spent on
# the app "survey"
apptime(oTree, pcode = "a7dppel1", apps = "survey")
#> [1] 0.23

# 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."
#> 
#> $warnings
#> [1] "164r1hs4"
#> 

# Show how much time all participants spent on all apps
apptime(oTree)
#> $chatapp
#> $chatapp$mean_duration
#> [1] 0.65
#> 
#> $chatapp$min_duration
#> [1] 0.02
#> 
#> $chatapp$max_duration
#> [1] 1.87
#> 
#> $chatapp$single_durations
#>    participant  session duration
#> 10    iagvtslv t0rog7nz     0.02
#> 11    jxh15obl t0rog7nz     0.07
#> 8     xx78b3x0 vd1h01iv     0.20
#> 16    7l0hmpcq qyu3qg0q     0.20
#> 9     xmxl46rm vd1h01iv     0.45
#> 17    ia9rnfvc qyu3qg0q     0.55
#> 4     3ttf7yix 7bfqtokx     0.57
#> 13    wk247s9w t0rog7nz     0.57
#> 12    a7dppel1 t0rog7nz     0.58
#> 7     lsl3vbij 7bfqtokx     0.60
#> 1     46kxib6w 7bfqtokx     0.62
#> 3     4zhzdmzo 7bfqtokx     0.77
#> 5     2d72mfgh 7bfqtokx     0.77
#> 14    xkobdvuh t0rog7nz     1.07
#> 6     rvce7958 7bfqtokx     1.08
#> 15    1l5kal0r t0rog7nz     1.10
#> 2     iay3dhkn 7bfqtokx     1.87
#> 
#> $chatapp$messages
#> [1] "For some participants, no duration could be calculated. See list in $warnings."
#> 
#> $chatapp$warnings
#> [1] "164r1hs4" "ktjz5jli" "vbhvhozv" "2scvem7a" "7wa8kk3d" "znri6myc" "ao9kqvqn"
#> [8] "d4sq7zio"
#> 
#> 
#> $dictator
#> $dictator$mean_duration
#> [1] 2.05
#> 
#> $dictator$min_duration
#> [1] 0.4
#> 
#> $dictator$max_duration
#> [1] 5.95
#> 
#> $dictator$single_durations
#>    participant  session duration
#> 12    vbhvhozv vd1h01iv     0.40
#> 13    2scvem7a vd1h01iv     0.43
#> 20    7l0hmpcq qyu3qg0q     0.43
#> 2     iay3dhkn 7bfqtokx     0.47
#> 21    ia9rnfvc qyu3qg0q     0.50
#> 1     46kxib6w 7bfqtokx     0.57
#> 11    xmxl46rm vd1h01iv     0.65
#> 10    xx78b3x0 vd1h01iv     0.72
#> 18    xkobdvuh t0rog7nz     0.90
#> 19    1l5kal0r t0rog7nz     0.95
#> 16    a7dppel1 t0rog7nz     1.17
#> 17    wk247s9w t0rog7nz     1.20
#> 15    jxh15obl t0rog7nz     1.58
#> 14    iagvtslv t0rog7nz     2.65
#> 9     ktjz5jli 7bfqtokx     2.88
#> 8     lsl3vbij 7bfqtokx     3.45
#> 7     164r1hs4 7bfqtokx     3.53
#> 6     rvce7958 7bfqtokx     4.37
#> 5     2d72mfgh 7bfqtokx     4.48
#> 3     4zhzdmzo 7bfqtokx     5.87
#> 4     3ttf7yix 7bfqtokx     5.95
#> 
#> $dictator$messages
#> [1] "For some participants, no duration could be calculated. See list in $warnings."
#> 
#> $dictator$warnings
#> [1] "7wa8kk3d" "znri6myc" "ao9kqvqn" "d4sq7zio"
#> 
#> 
#> $survey
#> $survey$mean_duration
#> [1] 0.28
#> 
#> $survey$min_duration
#> [1] 0.08
#> 
#> $survey$max_duration
#> [1] 1.13
#> 
#> $survey$single_durations
#>    participant  session duration
#> 11    jxh15obl t0rog7nz     0.08
#> 5     2d72mfgh 7bfqtokx     0.13
#> 7     lsl3vbij 7bfqtokx     0.13
#> 15    1l5kal0r t0rog7nz     0.13
#> 3     4zhzdmzo 7bfqtokx     0.15
#> 9     xmxl46rm vd1h01iv     0.15
#> 10    iagvtslv t0rog7nz     0.15
#> 16    7l0hmpcq qyu3qg0q     0.15
#> 17    ia9rnfvc qyu3qg0q     0.15
#> 8     xx78b3x0 vd1h01iv     0.17
#> 2     iay3dhkn 7bfqtokx     0.22
#> 6     rvce7958 7bfqtokx     0.22
#> 12    a7dppel1 t0rog7nz     0.23
#> 14    xkobdvuh t0rog7nz     0.40
#> 4     3ttf7yix 7bfqtokx     0.42
#> 13    wk247s9w t0rog7nz     0.73
#> 1     46kxib6w 7bfqtokx     1.13
#> 
#> $survey$messages
#> [1] "For some participants, no duration could be calculated. See list in $warnings."
#> 
#> $survey$warnings
#> [1] "164r1hs4" "ktjz5jli" "vbhvhozv" "2scvem7a" "7wa8kk3d" "znri6myc" "ao9kqvqn"
#> [8] "d4sq7zio"
#> 
#>