search for: checkduplicates

Displaying 1 result from an estimated 1 matches for "checkduplicates".

Did you mean: check_duplicate
2011 May 23
1
Remove duplicate elements in lists via recursive indexing
...Here, it's pretty simple to remove duplicated entries y <- c(1,2,3,1,1) idx.dupl <- which(duplicated(y)) y <- y[-idx.dupl] # / # LISTS x <- list(a=list(a.1.1=1, a.1.1=2, a.1.1=3)) x[[c(1,1)]] x[[c(1,2)]] # Should be removed. x[[c(1,3)]] # Should be removed. # Let's say a 'checkDuplicates' routine would give me: idx.dupl <- list(c(1,2), c(1,3)) # Remove first duplicate: x[[idx.dupl[[1]]]] <- NULL x # Problem: # Once I remove the first duplicate, my duplicate index would have to be # updated as well as there is not third element anymore. x[[idx.dupl[[2]]]] <- NULL # So...