[R] number of distinct values in a dataframe

Douglas Bates bates at stat.wisc.edu
Mon Sep 22 21:12:23 CEST 2003


Rado Bonk <rbonk at host.sk> writes:

> How can I found the number of a distinct values in a data frame
> (occurrence of distinct values)? The dataframe consists of several
> thousands integer numbers.

It is not clear if you are asking about the number of unique values in
a column in a data frame or the number of unique rows in a data frame.
If there is more than one column these answers could be different.

The first is question is the easier one. Just use

 length(unique(mydataframe$columnOfInterest))




More information about the R-help mailing list