| To: | Sarah Henderson <sarah.henderson@ubc.ca> |
|---|---|
| Subject: | Re: extract row name of matrix |
| From: | Sundar Dorai-Raj <sundar.dorai-raj@pdf.com> |
| Date: | Wed, 05 Oct 2005 12:42:37 -0500 |
| Cc: | s-news@lists.biostat.wustl.edu |
| In-reply-to: | <6.0.3.0.2.20051005131445.01f48d68@mail.interchange.ubc.ca> |
| Organization: | PDF Solutions, Inc. |
| References: | <6.0.3.0.2.20051005131445.01f48d68@mail.interchange.ubc.ca> |
| User-agent: | Mozilla Thunderbird 1.0.2 (Windows/20050317) |
Sarah Henderson wrote: Hello to all --My apologies for what I know to be an elementary question, but cannot seem to find the answer to.I would like to extract the row name of a matrix where the third column has it's maximum value. I know that dimnames(matrix)[1] gives the row names and that max(matrix[,3]) gives the maximum in the third column, but I just can't figure out how to put the two together. I tried dimnames(matrix)[1[max(matrix)[,3]] but that didn't work.A point in the right direction would be much appreciated. I'm using S-Plus 6.2 in Windows.Thanks, Sarah You want something that returns the index of the maximum. which.max <- function(x) which(x == max(x)) dimnames(m)[[1]][which.max(m[, 3])] HTH, --sundar |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | extract row name of matrix, Sarah Henderson |
|---|---|
| Next by Date: | Re: extract row name of matrix, Sarah Henderson |
| Previous by Thread: | extract row name of matrix, Sarah Henderson |
| Next by Thread: | Re: extract row name of matrix, Sarah Henderson |
| Indexes: | [Date] [Thread] [Top] [All Lists] |