[S] Minimum column value from a matrix

Erin Hodgess (hodgess@uhdux2.dt.uh.edu)
Tue, 27 Oct 1998 00:21:11 -0600

Dear S+ers

I am using S+ version 4 on Windows 95 PC.

Here is my question, please.
I have an n x 3 matrix, called w. In matrix w, I have 3 columns,
alpha, beta, and sigma. I would like to find the minimum of
w[,3], and copy that row. If the minimum occurs more than once,
the first row is enough.

I have a solution, but I believe that a more "elegant" solution
is possible. Here is my "ok" solution.
a1 <- w[,3] == min(w[,3])
z1 <- w[a1,]
z1 <- z1[1,]
Then the vector z1 contains the first row where the minimum is found.
It works, but is ugly.

Any help would be much appreciated.

Erin Hodgess
Assistant Professor
Dept. of Computer and Mathematical Sciences
University of Houston -- Downtown
e-mail: hodgess@uhdux2.dt.uh.edu
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news