crossed_join {timeplyr}R 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,
  log_limit = 8
)

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.

log_limit

The maximum log10 limit for expanded number of rows. Anything >= this results in an error.

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)


[Package timeplyr version 0.5.0 Index]