[R] indexing a vector
Jeff Miller
jdm at xnet.com
Tue May 8 01:55:29 CEST 2001
----- Original Message -----
From: Thomas Lumley <tlumley at u.washington.edu>
Sent: Monday, May 07, 2001 1:38 PM
> On Mon, 7 May 2001, David White wrote:
>
> >
> > Dear R-List,
> >
> > How can one look up the row/column number for a given value in a matrix
or
> > data.frame? For example in a matrix that contains only unique values
for
> > in [,1] how can I find value x in [,1] and report its row number?
> >
>
> match(x,matrix[,1])
>
> -thomas
As a follow up to this question, what's the easiest way to
find the column and row indicies for a specified value in a matrix,
when you don't know which column it's in (as assumed above)?
So if mymatrix <- matrix(c(3, 2, 4, 1), nrow = 2), what's the easiet
way
to see that the value 4 is in position (1, 2) ?
Thanks much,
Jeff Miller
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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