Learn R Programming

reconstructr (version 1.1.1)

session_length: Counts the length of each session within a set

Description

session_length takes a list of sessions (generated via reconstruct_sessions) and calculates the approximate length (in seconds) of each session. See the "session metrics" vignette for more details.

session_length does not compute the length of sessions that consist of a single event, unless single_page_sessions is set to true. Instead, it returns the numeric value -1 for those sessions.

Usage

session_length(sessions, padding_value = 430L, preserve_single_events = FALSE, strip_last = FALSE)

Arguments

sessions
a list of sessions, extracted via reconstruct_sessions
padding_value
the time to use for padding the session length, to accomodate the time spent idling on the last event in the session or (in the case of one-event sessions) the only event in the session.
preserve_single_events
whether to attempt to calculate values for single page sessions (TRUE), or ignore them and instead return the value -1 (FALSE). Set to FALSE by default.
strip_last
whether to strip the last event in a session (TRUE) or include it and attempt to calculate the time spent on it via padding_value. Set to FALSE by default.

Value

a vector of session length counts, in seconds, with -1 for sessions containing a single event (or not. See the single_page_sessions parameter).

See Also

reconstruct_sessions, for generating sessions, session_events for simply counting the number of events in each session, and bounce_rate for calculating the bounce rate of the session set overall.

Examples

Run this code
## Not run: 
# #With a sessionised dataset (see ?reconstruct_sessions for an example)
# lengths <- session_length(sessions = sessions, padding_value = 200, preserve_single_events = TRUE)
# ## End(Not run)

Run the code above in your browser using DataLab