[R] Creating vectors

TGS cran.questions at gmail.com
Thu Aug 12 17:42:55 CEST 2010


I think I understand your question and the following would produce the result you've posted.

(x <- matrix(c(1, 2, 2, 3, 1, 2, 1, 2, 3, 4), nrow=5, byrow=TRUE))

On Aug 12, 2010, at 5:41 AM, clips10 wrote:


Thanks for the help,

I tried to apply this to a vector with two columns, well I suppose it is not
a vector but for instance like this:

       [,1]  [,2]
[1,]    1      2
[2,]    2      3
[3,]    1      2
[4,]    1      2
[5,]    3     4

and return a vector :

1,2,1,1,3, so that it recognises both columns together.

I tried match(x, unique(x)) as earlier suggested but this returns a vector
of length 10 as opposed to 5, even though unique(x) does remove the repeated
rows.
Sorry if this is confusing, I am trying to do as originally posted but with
2 columns

Thanks
-- 
View this message in context: http://r.789695.n4.nabble.com/Creating-vectors-tp2321440p2322646.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