[R] How to count the number of different elements in a column
Rui Barradas
ruipbarradas at sapo.pt
Mon Nov 26 17:56:34 CET 2012
Hello,
You're wrong, unique doesn't count unique returns a vector without
repetitions.
unique(a) # includes 1 and 4
[1] 1 2 3 6 7 8 4
length(unique(a))
[1] 7
Hope this helps,
Rui Barradas
Em 26-11-2012 14:55, Hard Core escreveu:
> this is wrong because with the command "unique" it counts the only values
> that are unique ..
>
> in my column, for instance, 1 and 4 are not unique so the formula doesn't
> work in my case
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-count-the-number-of-different-elements-in-a-column-tp4650825p4650843.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list