How to avoid unlist() modification of list naming
list, r
Solution
unlist(unname(list1))
# 1 2 2 3 4 4 5 6 6 6
# 1 2 3 4 5 6 7 8 9 10
Problem
I am a bit puzzled by the names produced by `unlist()`. Please consider the following MWE ``` vector1 <- c(1,2,3,4,5,6,7,8,9,10) names(vector1) <- c(1,2,2,3,4,4,5,6,6,6) names(vector1) # [1] "1" "2" "2" "3" "4" "4" "5" "6" "6" "6" list1 <- split(vector1,names(vector1)) names(list1) # [1] "1" "2" "3" "4" "5" "6" ``` but then ``` names(unlist(list1)) # [1] "1.1" "2.2" "2.2" "3.3" "4.4" "4.4" "5.5" "6.6" "6.6" "6.6" ``` According to the documentation of `unlist()` By default, unlist tries to retain the naming information present in x. so I can't make sense of this particular behaviour. My problem is that the names as created by `unlist()` can't be matched against the names of the original `vector1`.