Re: [R] re moving rows from matrix

From: Yasir Kaheil <kaheil_at_gmail.com>
Date: Fri, 02 May 2008 12:01:11 -0700 (PDT)

you could do it using apply like the first two replies mentioned or you could just use the negative 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.

______________________________________________
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.
Received on Fri 02 May 2008 - 19:18:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 02 May 2008 - 19:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive