s-news
[Top] [All Lists]

Summary: This must be easy...

To: S-News <s-news@wubios.wustl.edu>
Subject: Summary: This must be easy...
From: "Kim Elmore" <Kim.Elmore@noaa.gov>
Date: Tue, 27 May 2003 11:45:02 -0500
My sincere thanks to all who responded. My question really boiled down to: How to extract an arbitrary vector form a matrix?

The nearly universal answer is

vector.of.matrix.elements <- matrix.of.data[cbind(row.index, column.index)]

where vector.of.matrix is the vector of matrix elements desired, matrix.of.data, is the matrix from which the elements are to be extracted, row.index and column.index are each vectors of the same length that specify which elements to extract. Alternatively, these may be thought of as two columns of a matrix, which is exactly what cbind() does.

I wish to thank: Brad Biggerstaff, Bill Dunlap, Tony Plate, Sam Buttrey, Steve McKinney, Andy Liaw, Patrick Burns (whose book I have but obviously haven't yet completely absorbed), Scott Seleska, Nick Ellis, and Erin Hodges for their useful, timely, informative replies.

All th ebest,

Kim Elmore
                          Kim Elmore, Ph.D.
                       University of Oklahoma
        Cooperative Institute for Mesoscale Meteorological Studies
"All of weather is divided into three parts: Yes, No, and Maybe. The
greatest of these is Maybe" The original Latin appears to be garbled.


<Prev in Thread] Current Thread [Next in Thread>
  • Summary: This must be easy..., Kim Elmore <=