Learn R Programming

reconstructr (version 1.1.1)

reconstruct_sessions: split a series of timestamps (or a series of series) associated with UUIDs, into sessions

Description

reconstruct_sessions splits timestamps associated with user events into "sessions", enabling the simple calculation of various metrics such as session length or the number of events within a session.

Usage

reconstruct_sessions(timestamps, threshold = 3600L)

Arguments

timestamps
a list of vectors of second values. These can be extracted by converting POSIXlt or POSIXct timestamps into numeric elements through a call to as.numeric, or with the assistance of to_seconds.
threshold
the threshold, in seconds, for splitting out a new session. Set to 3600 (one hour) by default.

Value

a list of vectors, each one representing a single session. The returned list can be conveniently passed into session_length or session_events for further analysis.

See Also

session_length for calculating session length, bounce_rate for calculating the bounce rate, and session_events for calculating the number of events in each session.

Examples

Run this code
#Take the inbuilt dataset and sessionise it
data("session_dataset")
session_dataset$timestamp <- to_seconds(x = session_dataset$timestamp, format = "%Y%m%d%H%M%S")
events_by_user <- split(session_dataset$timestamp, session_dataset$UUID)
sessions <- reconstruct_sessions(events_by_user)

Run the code above in your browser using DataLab