sum_durations {webtrackR}R Documentation

Summarize visit duration by person

Description

sum_durations() summarizes the duration of visits by person within a timeframe, and optionally by visit_class of visit. Note:

Usage

sum_durations(wt, var_duration = NULL, timeframe = NULL, visit_class = NULL)

Arguments

wt

webtrack data object.

var_duration

character. Name of the duration variable if already present. Defaults to NULL, in which case duration will be approximated with add_duration(wt, cutoff = 300, replace_by = "na", replace_val = NULL)

timeframe

character. Indicates for what time frame to aggregate visit durations. Possible values are "date", "week", "month", "year", "wave" or NULL. If set to "wave", wt must contain a column call wave. Defaults to NULL, in which case the output contains duration of visits for the entire time.

visit_class

character. Column that contains a classification of visits. For each value in this column, the output will have a column indicating the number of visits belonging to that value. Defaults to NULL.

Value

a data.frame with columns panelist_id, column indicating the time unit (unless timeframe set to NULL), duration_visits indicating the duration of visits (in seconds, or whatever the unit of the variable specified by var_duration parameter), and a column for each value of visit_class, if specified.

Examples

## Not run: 
data("testdt_tracking")
wt <- as.wt_dt(testdt_tracking)
# summarize for whole period
wt_summ <- sum_durations(wt)
# summarize by week
wt_summ <- sum_durations(wt, timeframe = "week")
# create a class variable to summarize by class
wt <- extract_domain(wt)
wt$google <- ifelse(wt$domain == "google.com", 1, 0)]
wt_summ <- sum_durations(wt, timeframe = "week", visit_class = "google")

## End(Not run)

[Package webtrackR version 0.3.1 Index]