Accumulate values for every possible combination in R
6
Let's say I have data test (dput given) where a list-col say items : test <- structure(list(items = list('a', c('b', 'c'), c('d', 'e'), 'f', c('g', 'h')), ID = c(1,1,1,2,2)), row.names = c(NA, 5L), class = "data.frame") library(tidyverse) test %>% group_by(ID) %>% mutate(dummy = accumulate(items, ~paste(.x, .y))) I am getting an output with list-col like this items ID dummy 1 a 1 a 2 b, c 1 a b, a c 3 d, e 1 a b d, a c e 4 f 2 f 5 g, h 2 f g, f h I would like there to be four items in row3, having each possible combination, i.e. c("a b d", "a b e", "a c d", "a c e")...