cross_join: Crossing join

View source: R/cross_join.R

cross_joinR Documentation

Crossing join

Description

Adds columns from a set of data frames, creating all combinations of their rows

Usage

cross_join(..., copy = FALSE)

Arguments

...

Data frames or a list of data frames – including data frame extensions (e.g. tibbles) and lazy data frames (e.g. from dbplyr or dtplyr). NULL inputs are silently ignored.

copy

If inputs are not from the same data source, and copy is TRUE, then they will be copied into the same src as the first input. This allows you to join tables across srcs, but it is a potentially expensive operation so you must opt into it.

Value

An object of the same type as the first input. The order of the rows and columns of the first input is preserved as much as possible. The output has the following properties:

  • Rows from each input will be duplicated.

  • Output columns include all columns from each input. If columns have the same name, suffixes are added to disambiguate.

  • Groups are taken from the first input.

See Also

cross_list() to find combinations of elements of vectors and lists.

Examples

fruits <- dplyr::tibble(
  fruit = c("apple", "banana", "cantaloupe"),
  color = c("red", "yellow", "orange")
)

desserts <- dplyr::tibble(
  dessert = c("cupcake", "muffin", "streudel"),
  makes   = c(8, 6, 1)
)

cross_join(fruits, desserts)
cross_join(list(fruits, desserts))
cross_join(rep(list(fruits), 3))

crossmap documentation built on Jan. 13, 2023, 1:13 a.m.