Cross Join in dplyr in R
As of dplyr
version 1.0, you can do a cross join by specifying by = character()
:
cust_time %>% full_join(cust_time, by = character())
You just need a dummy column to join on:
cust_time$k <- 1
cust_time %>%
inner_join(cust_time, by='k') %>%
select(-k)
Or if you don't want to modify your original dataframe:
cust_time %>%
mutate(k = 1) %>%
replicate(2, ., simplify=FALSE) %>%
Reduce(function(a, b) inner_join(a, b, by='k'), .) %>%
select(-k)