x <- list(a = 1:3, b = 2, c = 2:4)
y <- c(a = 1, b = 1, c = 1, d = 2, e = 3, f = 3)
# unlist0() doesn't force unique names
unlist(x) # names: a1 a2 a3 b c1 c2 c3
unlist0(x) # names: a a a b c c c
unlist0(y) # no change
# squash_vec() is like the inverse of unlist0() because it works on values
squash_vec(x)
squash_vec(y)
Run the code above in your browser using DataLab