fruits <- memdb_frame(
type = c("apple", "orange", "apple", "orange", "orange", "orange"),
year = c(2010, 2010, 2012, 2010, 2010, 2012),
size = c("XS", "S", "M", "S", "S", "M"),
weights = rnorm(6)
)
# All possible combinations ---------------------------------------
fruits %>% tidyr::expand(type)
fruits %>% tidyr::expand(type, size)
# Only combinations that already appear in the data ---------------
fruits %>% tidyr::expand(nesting(type, size))
Run the code above in your browser using DataLab