[R] finding dedicated indexes?

Peter Wolf pwolf at wiwi.uni-bielefeld.de
Tue Mar 20 17:43:06 CET 2001


Thomas Bruns wrote:

> I've got a matrix of two columns, say:
> > d <- t(array(1:20,dim=c(2,10)))
> ...
> now I need those values from column #2 where column #1 is equal to
> certain values. eg.:
> > i <- c(13,5,19)
> The following doesn't work but you may get the idea:
> >print( d[ d[,1]==i ,2])

Hello Thomas, 
what about:

> d <- t(array(1:20,dim=c(2,10)))
> i <- c(13,5,19)
> d[match(i,d[,1]), 2]
[1] 14  6 20

Peter

------------------------------------------------------------
Dr. Peter Wolf			pwolf at wiwi.uni-bielefelde.de
Statistik/Informatik
Wirtschaftswissenschaften
Uni Bielefeld
Bielefeld 
Germany
------------------------------------------------------------


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list