sessionise: Reconstruct sessions (experimental)

Description Usage Arguments Value See Also Examples

View source: R/sessionise.R

Description

sessionise takes a data.frame of events (including timestamps and user IDs) and sessionises them, returning the same data.frame but with two additional columns - one containing a unique session ID, and one the time difference between successive events in the same session.

Usage

1
sessionise(x, timestamp, user_id, threshold = 3600)

Arguments

x

a data.frame of events.

timestamp

the name of the column of x containing timestamps, which should be (either) a representation of the number of seconds, or a POSIXct or POSIXlt date/time object. If it is neither, strptime can be used to convert most representations of date-times into POSIX formats.

user_id

the name of the column of x containing unique user IDs.

threshold

the number of seconds to use as the intertime threshold - the time that can elapse between two events before the second is considered part of a new session. Set to 3600 (one hour) by default.

Value

x, ordered by userID and timestamp, with two new columns - session_id (containing a unique ID for the session a row is in) and delta (containing the time elapsed between that row's event, and the previous event, if they were both in the same session).

See Also

bounce_rate, time_on_page, session_length and session_count - common metrics that can be calculated with a sessionised dataset.

Examples

1
2
3
4
5
6
7
8
# Take a dataset with URLs and similar metadata and sessionise it -
# retaining that metadata

data("session_dataset")
sessionised_data <- sessionise(x = session_dataset,
                              timestamp = timestamp,
                              user_id = uuid,
                              threshold = 1800)

Ironholds/reconstructr documentation built on Feb. 14, 2022, 9:01 p.m.