gfgm
gfgm

Reputation: 3647

removing duplicated sets from a list in r

I have a list of vectors, where each vector contains the same number of character strings, e.g.

LL <- list(c('A','B'), c('B', 'A'), c('C', 'D'), c('D', 'C'))

I would like to remove entries that are duplicated sets, such that the result would be:

LL

[[1]] [1] "A" "B"

[[2]] [1] "C" "D"

It does not matter which of the duplicated sets is kept, or if the order of the sets is changed.

Upvotes: 3

Views: 2013

Answers (1)

Ananta
Ananta

Reputation: 3711

may be this

unique(lapply(LL, sort))

Upvotes: 5

Related Questions