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))
Dear Rado and Doug, At 02:13 PM 9/22/2003 -0500, Douglas Bates wrote:>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))Since the data frame consists entirely of numeric values, finding the number of unique values in the data frame as a whole isn't much harder: length(unique(as.vector(as.matrix(mydataframe)))) Regards, John ____________________________ John Fox Department of Sociology McMaster University email: jfox at mcmaster.ca web: http://www.socsci.mcmaster.ca/jfox
On Mon, 22 Sep 2003, Douglas Bates wrote:> 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)) >The same works for the second question length(unique(mydataframe)) -thomas
Hi R-users, 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. Thanks, Rado -- Radoslav Bonk M.S. Dept. of Physical Geography and Geoecology Faculty of Sciences, Comenius University Mlynska Dolina 842 15, Bratislava, SLOVAKIA tel: +421 905 968 127 e-mail: rbonk at host.sk