[R] Extracting vectors from matrices

Anon. bob.ohara at helsinki.fi
Fri Oct 27 09:22:24 CEST 2000


There is probably a simple and obvious answer to this, so sorry for
wasting your time...

I have a matrix of predictions from an proportional odds model (using
the polr function in MASS), so the columns are the probabilities of the
responses, and the rows are the data points.  I have another column with
the observed responses, and I want to extract the probabilities for the
observed responses.

As a toy example, if I have 
x <- matrix(c(1,2,3,4,5,6),2,3)
y <- c(1,3)
and I want to extract the numbers in x[1,1] and x[2,3] (the columns
being indexed from y), what do I do?

Bob

-- 
Bob O'Hara
Metapopulation Research Group
Division of Population Biology
Department of Ecology and Systematics
PO Box 17 (Arkadiankatu 7)
FIN-00014 University of Helsinki
Finland

tel: +358 9 191 7382  fax: +358 9 191 7301 
email: bob.ohara at helsinki.fi
To induce catatonia, visit:
http://www.helsinki.fi/science/metapop/

I have yet to see any problem, however complicated, which, when you
looked at it in the right way, did not become still more complicated.  -
Poul Anderson
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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