[R] re moving rows from matrix

Yasir Kaheil kaheil at gmail.com
Fri May 2 21:04:09 CEST 2008


you could do it using apply like the first two replies mentioned or you could
just use the index way
for example: (assuming your matrix name is ym and the values are greater
than 25 and less than 50 and the column is column 3).. if you mean "any
column" use the first two replies.

> ym<-array(runif(10,20,100),c(6,5)); ym
         [,1]     [,2]     [,3]     [,4]     [,5]
[1,] 97.57168 52.22471 41.23411 91.78960 22.57583
[2,] 41.17106 23.73572 55.77120 27.47041 37.94204
[3,] 41.23411 91.78960 22.57583 97.57168 52.22471
[4,] 55.77120 27.47041 37.94204 41.17106 23.73572
[5,] 22.57583 97.57168 52.22471 41.23411 91.78960
[6,] 37.94204 41.17106 23.73572 55.77120 27.47041
> ym<-ym[(ym[,3]>25) & (ym[,3] <50),]; ym
         [,1]     [,2]     [,3]     [,4]     [,5]
[1,] 97.57168 52.22471 41.23411 91.78960 22.57583
[2,] 55.77120 27.47041 37.94204 41.17106 23.73572


thanks



Monna Nygård wrote:
> 
> 
>  Hi, I have a problem regarding matrix handeling. I am working with a
> serie of matrixes containing several columns. Now I would like to delete
> those rows of the matrixes,that in one of the columns contain values less
> than 50 or greater than 1000. How would this be possible, I have tried to
> create a simple function for this, but I just don't seem to get it
> right.Thank you so much for your help, Monna  
> _________________________________________________________________
> [[elided Hotmail spam]]
> 
> PLink
> 	[[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.
> 
> 

-- 
View this message in context: http://www.nabble.com/removing-rows-from-matrix-tp17016646p17025836.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list