[R] Unique Values of a Matrix

Henrique Dallazuanna wwwhsd at gmail.com
Fri Feb 26 14:17:28 CET 2010


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