stitch: stitch

Description Usage Arguments Details Examples

View source: R/stitch.R

Description

Safe Left-Join for training/scoring data creation

Usage

1
2
3
4
5
6
7
stitch(lhs, rhs, on = NULL, ...)

## S3 method for class 'data.frame'
stitch(lhs, rhs, on = NULL, ...)

## S3 method for class 'data.table'
stitch(lhs, rhs, on = NULL, rhs.prefix = deparse(substitute(rhs)))

Arguments

lhs

data; left-handed side for LEFT JOIN

rhs

data; right-handed side data for LEFT JOIN

on

character; join specification see data.table::data.table()

rhs.prefix

character; prefix for columns from the right

Details

stitch provides safe LEFT JOINS for building rectangularized tables, the kind used for modeling and other analyses.

  1. Supports LEFT JOINS using on, key or a natural join

  2. Preserves column ordering keeping LHS names on the left.

  3. Handles column name collisions by auto prefixing the right-side data

  4. Preserves column ordering.

Examples

1
2
3
4
5
require(data.table)
left <- data.table( id = c(1,1,2,2,4), amount=1:5 )
right <- data.table( id = 1:6, type=letters[1:6]  )

left %>% stitch(right)

decisionpatterns/stitch documentation built on Sept. 9, 2020, 12:43 a.m.