crossed_join: A 'do.call()' and 'data.table::CJ()' method

View source: R/crossed_join.R

crossed_joinR Documentation

A do.call() and data.table::CJ() method

Description

This function operates like do.call(CJ, ...) and accepts a list or data.frame as an argument.
It has less overhead for small joins, especially when unique = FALSE and as_dt = FALSE.
NAs are by default sorted last.

Usage

crossed_join(
  X,
  sort = FALSE,
  unique = TRUE,
  as_dt = TRUE,
  strings_as_factors = FALSE
)

Arguments

X

A list or data frame.

sort

Should the expansion be sorted? By default it is FALSE.

unique

Should unique values across each column or list element be taken? By default this is TRUE.

as_dt

Should result be a data.table? By default this is TRUE. If FALSE a list is returned.

strings_as_factors

Should strings be converted to factors before expansion? The default is FALSE but setting to TRUE can offer a significant speed improvement.

Details

An important note is that currently NAs are sorted last and therefore a key is not set.

Value

A data.table or list object.

Examples

library(timeplyr)

crossed_join(list(1:3, -2:2))
crossed_join(iris)


timeplyr documentation built on June 22, 2024, 10:01 a.m.