I have a vector of lists (effectively a 2D array). The lists contain certain IDs and the number of IDs vary from list to list. I want to sort the vector based on the lists (first ID -> second ID ->.. and so on). Also I want to find the number of duplicates occurring in the vector. (Duplicates would be same IDs in separate lists in any permutation). For example:
vec = c( list(c(1,2)),list(c(1,2,3)),list(c(1,2)),list(c(2,3)),list(c(1,3,2)) )
vec
[[1]]
[1] 1 2
[[2]]
[1] 1 2 3
[[3]]
[1] 1 2
[[4]]
[1] 2 3
[[5]]
[1] 1 3 2
I want the output to sort the lists and provide the number of duplicates. Hence, the output must be in the order: [[1]] -> [[2]] -> [[4]] with frequencies (2,2,1).