I'm having issues removing just the right amount of information from the following data:
18,14,17,2,9,8
17,17,17,14
18,14,17,2,1,1,1,1,9,8,1,1,1
I'm applying !duplicate in order to remove the duplicates.
SplitFunction <- function(x) {
b <- unlist(strsplit(x, '[,]'))
c <- b[!duplicated(b)]
return(paste(c, collapse=","))
}
I'm having issues removing only consecutive duplicates. The result below is what I'm getting.
18,14,17,2,9,8
17,14
18,14,17,2,1,9,8
The data below is what I want to obtain.
18,14,17,2,9,8
17,14
18,14,17,2,1,9,8,1
Can you suggest a way to perform this? Ideally a vectorized approach...
Thanks,
Miguel