Calculate the time spent on the experiment. If not stated otherwise, the calculation only starts at the end of the first page!
Usage
extime(
oTree,
pcode = NULL,
plabel = NULL,
group_id = NULL,
seconds = FALSE,
rounded = TRUE,
digits = 2L,
startat = 1L,
tz = "UTC",
sinfo = "session_code",
combine = TRUE
)
Arguments
- oTree
A list of data frames that were created by
import_otree
.- 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 withmake_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
.- startat
Integer or character string
"real"
Whether the start of the experiment should be taken from the time at a certain index of each person's vector of page_indexes in the$Time
data frame or from thetime_started
variable in$all_apps_wide
("real"
). Important: If integer, it represents the position within the page index sequence, not the numeric value of thepage_index
variable.- tz
Character. Time zone.
- sinfo
Character.
"session_id"
to use session ID for additional information in the data frame of single durations,"session_code"
to use session codes, orNULL
if no session column should be shown.- combine
Logical.
TRUE
if all variables referring to epoch time should be merged, and all variables referring to participant code should be merged in case data of several versions of oTree are used. IfFALSE
, the function returns an error if several oTree versions' data are present.
Value
This function returns either a single value if only the data of one person is calculated or a list of information on the time several participants spent on the experiment.
In this list, you can find the following information:
- $mean_duration
= The experiment's average duration.
- $min_duration
= The experiment's minimum duration.
- $max_duration
= The experiment's maximum duration.
- $single_durations
= A data frame of all durations that
are used for calculating the min, max, and mean duration.
- $messages
= All important notes to the calculations.
- $only_one_page
= A vector of all individuals who
only have one time stamp.
Details
This functions calculates the time spent on the experiment by using
the variable that refers to the time stamp. If that variable is not
present, the function alternatively uses seconds_on_page2
,
which can be created with the pagesec
function.
Examples
# Use package-internal list of oTree data frames
oTree <- gmoTree::oTree
# Show time for one participant
extime(oTree, pcode = "wk247s9w")
#> [1] 2.5
# Make a data frame of durations
extime(oTree)
#> $mean_duration
#> [1] 2.81
#>
#> $min_duration
#> [1] 0.4
#>
#> $max_duration
#> [1] 6.93
#>
#> $single_durations
#> participant session duration
#> 12 vbhvhozv vd1h01iv 0.40
#> 13 2scvem7a vd1h01iv 0.43
#> 20 7l0hmpcq qyu3qg0q 0.78
#> 10 xx78b3x0 vd1h01iv 1.08
#> 21 ia9rnfvc qyu3qg0q 1.20
#> 11 xmxl46rm vd1h01iv 1.25
#> 15 jxh15obl t0rog7nz 1.73
#> 16 a7dppel1 t0rog7nz 1.98
#> 19 1l5kal0r t0rog7nz 2.18
#> 1 46kxib6w 7bfqtokx 2.32
#> 18 xkobdvuh t0rog7nz 2.37
#> 17 wk247s9w t0rog7nz 2.50
#> 2 iay3dhkn 7bfqtokx 2.55
#> 14 iagvtslv t0rog7nz 2.82
#> 9 ktjz5jli 7bfqtokx 2.88
#> 7 164r1hs4 7bfqtokx 3.53
#> 8 lsl3vbij 7bfqtokx 4.18
#> 5 2d72mfgh 7bfqtokx 5.38
#> 6 rvce7958 7bfqtokx 5.67
#> 3 4zhzdmzo 7bfqtokx 6.78
#> 4 3ttf7yix 7bfqtokx 6.93
#>
#> $messages
#> [1] "Warning: For at least one participant, the experiment only has one page. I.e., the indices for the first and the last page are the same. See $only_one_page for information on this participant/these participants! Participants in this list are not included in the output."
#>
#> $only_one_page
#> [1] "7wa8kk3d" "znri6myc" "ao9kqvqn" "d4sq7zio"
#>
# Make a data frame of durations (beginning from the end of the second page)
extime(oTree, startat = 2)
#> $mean_duration
#> [1] 1.88
#>
#> $min_duration
#> [1] 0.03
#>
#> $max_duration
#> [1] 6.08
#>
#> $single_durations
#> participant session duration
#> 13 2scvem7a vd1h01iv 0.03
#> 9 ktjz5jli 7bfqtokx 0.05
#> 12 vbhvhozv vd1h01iv 0.15
#> 20 7l0hmpcq qyu3qg0q 0.63
#> 7 164r1hs4 7bfqtokx 0.82
#> 10 xx78b3x0 vd1h01iv 1.03
#> 11 xmxl46rm vd1h01iv 1.08
#> 21 ia9rnfvc qyu3qg0q 1.08
#> 8 lsl3vbij 7bfqtokx 1.40
#> 15 jxh15obl t0rog7nz 1.53
#> 16 a7dppel1 t0rog7nz 1.78
#> 19 1l5kal0r t0rog7nz 1.98
#> 18 xkobdvuh t0rog7nz 2.17
#> 1 46kxib6w 7bfqtokx 2.20
#> 17 wk247s9w t0rog7nz 2.32
#> 2 iay3dhkn 7bfqtokx 2.37
#> 14 iagvtslv t0rog7nz 2.70
#> 5 2d72mfgh 7bfqtokx 2.73
#> 6 rvce7958 7bfqtokx 2.97
#> 4 3ttf7yix 7bfqtokx 4.35
#> 3 4zhzdmzo 7bfqtokx 6.08
#>
#> $messages
#> [1] "Warning: For at least one participant, the experiment only has one page. I.e., the indices for the first and the last page are the same. See $only_one_page for information on this participant/these participants! Participants in this list are not included in the output."
#>
#> $only_one_page
#> [1] "7wa8kk3d" "znri6myc" "ao9kqvqn" "d4sq7zio"
#>