cross_join {crossmap} | R 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).
|
copy |
If inputs are not from the same data source, and copy is
|
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))