Skip to contents

Behaves like subsetting a data frame, with three additions. If the result no longer carries the columns that make a journey table a journey table, the mm_paths class is dropped and a plain data frame is returned, so a column subset cannot produce an object that claims to be an mm_paths but cannot answer any question about journeys. Rows selected by a missing (NA) row index are dropped with a message, as subset() drops them. And touch_rank and touch_n are recomputed whenever they no longer match the rows present.

Usage

# S3 method for class 'mm_paths'
x[...]

Arguments

x

An mm_paths object.

...

Passed to the data frame method.

Value

An mm_paths object when the structural columns survive, otherwise a plain data frame.

Details

When a row subset removes part of a journey, dropping one channel say, the first remaining touch becomes rank 1 and the result is a valid journey table in its own right, so every credit rule sums to 1 per converting journey. A row selected twice counts as two touches. Construction counts describe the table build_paths() returned, so they are dropped once rows change. Convert with as.data.frame() first to inspect the original ranks of a partial selection.

The dplyr verbs follow the same rules: filter(), slice(), arrange() and distinct() subset rows as [ does, and mutate() and the joins recompute ranks the same way. Journey tables built by separate build_paths() calls share journey ids; combine them with bind_paths().

Examples

data(mm_events)
paths <- build_paths(mm_events, id = "customer_id", channel = "channel",
                     timestamp = "timestamp", conversion = "conversion")

# Row subset: still a journey table
class(paths[paths$converted, ])
#> [1] "mm_paths"   "data.frame"

# Column subset that drops the structure: plain data frame
class(paths[, c("channel", "touch_rank")])
#> [1] "data.frame"