Skip to contents

Create a new variable in the $Time data frame that contains the time spent on each page.

Usage

pagesec(oTree, rounded = TRUE, digits = 2, minutes = FALSE, combine = FALSE)

Arguments

oTree

A list of data frames that were created by import_otree.

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.

minutes

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

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.

Value

This function returns a duplicate of the original oTree list of data frames that also contains a column in the $Time data frame named seconds_on_page2 or minutes_on_page.

Examples

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

# Create two new columns: seconds_on_page2 and minutes_on_page
oTree <- pagesec(oTree, rounded = TRUE, minutes = TRUE)

# Show the Time data frame
head(oTree$Time, n = 30)
#>    session_code participant_id_in_session participant_code page_index app_name
#> 1      7bfqtokx                         1         46kxib6w          0         
#> 2      7bfqtokx                         2         iay3dhkn          0         
#> 3      7bfqtokx                         3         4zhzdmzo          0         
#> 4      7bfqtokx                         4         3ttf7yix          0         
#> 5      7bfqtokx                         5         2d72mfgh          0         
#> 6      7bfqtokx                         6         rvce7958          0         
#> 7      7bfqtokx                         7         164r1hs4          0         
#> 8      7bfqtokx                         8         lsl3vbij          0         
#> 9      7bfqtokx                         9         ktjz5jli          0         
#> 10     7bfqtokx                         1         46kxib6w          1 dictator
#> 11     7bfqtokx                         1         46kxib6w          2 dictator
#> 12     7bfqtokx                         2         iay3dhkn          1 dictator
#> 13     7bfqtokx                         1         46kxib6w          3 dictator
#> 14     7bfqtokx                         2         iay3dhkn          3 dictator
#> 15     7bfqtokx                         2         iay3dhkn          4 dictator
#> 16     7bfqtokx                         2         iay3dhkn          5 dictator
#> 17     7bfqtokx                         1         46kxib6w          4 dictator
#> 18     7bfqtokx                         1         46kxib6w          5 dictator
#> 19     7bfqtokx                         1         46kxib6w          6 dictator
#> 20     7bfqtokx                         1         46kxib6w          7 dictator
#> 21     7bfqtokx                         2         iay3dhkn          7 dictator
#> 22     7bfqtokx                         1         46kxib6w          8 dictator
#> 23     7bfqtokx                         1         46kxib6w          9 dictator
#> 24     7bfqtokx                         1         46kxib6w         10 dictator
#> 25     7bfqtokx                         2         iay3dhkn          8 dictator
#> 26     7bfqtokx                         2         iay3dhkn          9 dictator
#> 27     7bfqtokx                         1         46kxib6w         11 dictator
#> 28     7bfqtokx                         2         iay3dhkn         11 dictator
#> 29     7bfqtokx                         2         iay3dhkn         12 dictator
#> 30     7bfqtokx                         1         46kxib6w         12 dictator
#>                page_name epoch_time_completed round_number timeout_happened
#> 1  InitializeParticipant           1679926144            1                0
#> 2  InitializeParticipant           1679926145            1                0
#> 3  InitializeParticipant           1679926146            1                0
#> 4  InitializeParticipant           1679926146            1                0
#> 5  InitializeParticipant           1679926147            1                0
#> 6  InitializeParticipant           1679926147            1                0
#> 7  InitializeParticipant           1679926148            1                0
#> 8  InitializeParticipant           1679926148            1                0
#> 9  InitializeParticipant           1679926149            1                0
#> 10          Introduction           1679926151            1                0
#> 11                 Offer           1679926154            1                0
#> 12          Introduction           1679926156            1                0
#> 13       ResultsWaitPage           1679926156            1                0
#> 14       ResultsWaitPage           1679926156            1                0
#> 15               Results           1679926157            1                0
#> 16          Introduction           1679926158            2                0
#> 17               Results           1679926160            1                0
#> 18          Introduction           1679926162            2                0
#> 19                 Offer           1679926165            2                0
#> 20       ResultsWaitPage           1679926165            2                0
#> 21       ResultsWaitPage           1679926165            2                0
#> 22               Results           1679926166            2                0
#> 23          Introduction           1679926167            3                0
#> 24                 Offer           1679926169            3                0
#> 25               Results           1679926171            2                0
#> 26          Introduction           1679926172            3                0
#> 27       ResultsWaitPage           1679926172            3                0
#> 28       ResultsWaitPage           1679926172            3                0
#> 29               Results           1679926173            3                0
#> 30               Results           1679926178            3                0
#>    is_wait_page minutes_on_page
#> 1             0              NA
#> 2             0              NA
#> 3             0              NA
#> 4             0              NA
#> 5             0              NA
#> 6             0              NA
#> 7             0              NA
#> 8             0              NA
#> 9             0              NA
#> 10            0            0.12
#> 11            0            0.05
#> 12            0            0.18
#> 13            1            0.03
#> 14            1            0.00
#> 15            0            0.02
#> 16            0            0.02
#> 17            0            0.07
#> 18            0            0.03
#> 19            0            0.05
#> 20            1            0.00
#> 21            1            0.12
#> 22            0            0.02
#> 23            0            0.02
#> 24            0            0.03
#> 25            0            0.10
#> 26            0            0.02
#> 27            1            0.05
#> 28            1            0.00
#> 29            0            0.02
#> 30            0            0.10