[R] counting the duplicates in an object of list

zhenjiang xu zhenjiang.xu at gmail.com
Wed Aug 31 18:24:59 CEST 2011


Hi all,

I have a list x:

 > x=list(a=c('1','2'),b=c('2','3'),c=c('1','2'),d=c('2','3'))

I can get the unique elements with unique(), but how can I get the
number of duplicates for each unique elements?

> unique(x)
[[1]]
[1] "1" "2"

[[2]]
[1] "2" "3"

Thanks

--
Best,
Zhenjiang



More information about the R-help mailing list