# Sample a variable number of elements from each column and
# concatenate the results
var_select <- function(x) sample(x, size = rdunif(1, 5))
c(mtcars) %>% flatmap(var_select)
# You can also check that the results are of expected type
c(mtcars) %>% flatmap(var_select, .type = "character")
c(mtcars) %>% flatmap(var_select, .type = "numeric")
Run the code above in your browser using DataLab