Use crossing from the tidyr
package:
x <- data.frame(x=c("a","b","c"))
y <- data.frame(y=c(1,2,3))
crossing(x, y)
Result:
x y
1 a 1
2 a 2
3 a 3
4 b 1
5 b 2
6 b 3
7 c 1
8 c 2
9 c 3
More Related Contents:
- Gather multiple sets of columns
- How to get summary statistics by group
- Is there a dplyr equivalent to data.table::rleid?
- Replace NA with previous or next value, by group, using dplyr
- Filter rows which contain a certain string
- Calculate group mean, sum, or other summary stats. and assign column to original data
- Rolling mean (moving average) by group/id with dplyr
- Programming with dplyr using string as input
- Count number of rows by group using dplyr
- Pass a vector of variable names to arrange() in dplyr
- How to remove rows with any zero value
- Efficient way to filter one data frame by ranges in another
- R – add column that counts sequentially within groups but repeats for duplicates
- Categorize numeric variable with mutate
- Means multiple columns by multiple groups [duplicate]
- How to aggregate a dataframe by week?
- How to use map from purrr with dplyr::mutate to create multiple new columns based on column pairs
- Conditional cumsum with reset
- How to speed up subset by groups
- Use rle to group by runs when using dplyr
- Number of significant digits in dplyr summarise
- Calculate group mean while excluding current observation using dplyr
- Emulate split() with dplyr group_by: return a list of data frames
- Sparklyr: how to center a Spark table based on column?
- R: x ‘probs’ outside [0,1]
- dplyr::mutate to add multiple values
- Canonical tidyverse method to update some values of a vector from a look-up table
- Spreading a two column data frame with tidyr
- R dplyr rowwise mean or min and other methods?
- Collapse all columns by an ID column [duplicate]