[R] Unique Values of a Matrix

Todd DeWees T.DeWees at cpse.dundee.ac.uk
Fri Feb 26 14:43:03 CET 2010


Thank you.  That worked.  I had tried it before and failed, but after checking with you I realized that the problem was that my data was in a frame instead of a matrix.

Thanks again, 
Todd

Todd DeWees, PhD
Statistician
University of Dundee
Mackenzie Building
Kirsty Semple Way
Dundee DD2 4BF
Scotland UK
PH: 01382-420119


-----Original Message-----
From: Henrique Dallazuanna [mailto:wwwhsd at gmail.com] 
Sent: 26 February 2010 1:17 PM
To: Todd DeWees
Cc: r-help at r-project.org
Subject: Re: [R] Unique Values of a Matrix

Try this:

unique(c(X))

On Fri, Feb 26, 2010 at 10:06 AM, Todd DeWees
<T.DeWees at cpse.dundee.ac.uk> wrote:
> I have a 280,000 x 11 matrix with various values and many NA values.  What I would like to do is get a vector of every unique value in the matrix.
>
> For example:
>
> X =     [ 1    2    NA
>          4    3      1
>          7  NA  2 ]
>
> Returns:
> Unique_X = [ 1, 2, 3, 4, 7]
>
> Thanks,
> Todd
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list