[R] Help on finding specific columns in matrix

arun smartpink111 at yahoo.com
Sun Sep 2 23:10:33 CEST 2012



HI Andras,
No problem.  
But, i guess using colMeans() as suggested by Rainer should be faster in large datasets.

A.K.

----- Original Message -----
From: Andras Farkas <motyocska at yahoo.com>
To: smartpink111 at yahoo.com
Cc: 
Sent: Sunday, September 2, 2012 4:59 PM
Subject: Re: [R] Help on finding specific columns in  matrix




this works nicely, thanks arun...

Andras

------------------------------
On Sun, Sep 2, 2012 11:50 AM EDT arun wrote:

>Hi,
>Try this:
> which.min(apply(a,2,mean))
>#[1] 1
> which.max(apply(a,2,mean))
>#[1] 4
>A.K.
>
>
>
>
>----- Original Message -----
>From: Andras Farkas <motyocska at yahoo.com>
>To: "r-help at r-project.org" <r-help at r-project.org>
>Cc: 
>Sent: Sunday, September 2, 2012 5:49 AM
>Subject: [R] Help on finding specific columns in  matrix
>
>Dear All,
> 
>I have a matrix with 33 columns and 5000 rows. I would like to find 2 specific columns in the set: the one that holds the highest values and the one that holds the lowest values. In this case the column's mean would be apropriate to use to try to find those specific columns because each columns mean is different and they all change together based on the same "change of rate constants" as a function of time (ie: tme is the most important determinant of the magnitude of that mean).  The columns are not to be named, if possible.... Any thoughts on that? Would apreciate the help....
> 
>example:
> 
>a <-matrix(c(runif(500,10,15),runif(500,15,20),runif(500,20,25),runif(500,25,30)),ncol=4)
> 
>I would need to find and plot with a box percentile plot column 1, the column with the lowest mean, and column 4, the column with the highest mean
> 
>thanks,
> 
>Andras 
>    [[alternative HTML version deleted]]
>
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list