I have a single list of numeric vector and I want to combine them into one vector. But I am unable to do that. This list can have one element common across the list element. Fin
Another answer using Reduce()
.
Create the list of vectors:
lst <- list(c(1,2),c(2,4,5),c(5,9,1))
Combine them into one vector
vec <- Reduce(c,lst)
vec
# [1] 1 2 2 4 5 5 9 1
Keep the repeated ones only once:
unique(Reduce(c,lst))
#[1] 1 2 4 5 9
If you want to keep that repeated one at the end, You might want to use vec[which(c(1,diff(vec)) != 0)]
as in @Rachid's answer