Jun
5
Understanding data.table Rolling Joins
Understanding data.table Rolling Joins
Robert Norberg
June 5, 2016
Introduction
Rolling joins in data.table are incredibly useful, but not that well documented. I wrote this to help myself figure out how to use them and perhaps it can help you too.
library(data.table)
The Setup
Imagine we have an eCommerce website that uses a third party (like PayPal) to handle payments. We track user sessions on our website and PayPal tracks our payments, and we would like to attribute sales to user sessions. This way we can answer all kinds of questions along the lines of โWhat types of sessions lead to sales?โ
Lets create some example data for a diverse group of customers.
Indecisive Isabel shops a lot before she buys anything.
Robert Norberg
June 5, 2016
Introduction
Rolling joins in data.table are incredibly useful, but not that well documented. I wrote this to help myself figure out how to use them and perhaps it can help you too.
library(data.table)
The Setup
Imagine we have an eCommerce website that uses a third party (like PayPal) to handle payments. We track user sessions on our website and PayPal tracks our payments, and we would like to attribute sales to user sessions. This way we can answer all kinds of questions along the lines of โWhat types of sessions lead to sales?โ
Lets create some example data for a diverse group of customers.
Indecisive Isabel shops a lot before she buys anything.