Re: [R] delete rows whose sum is X

2011-03-04 Thread Uwe Ligges
On 04.03.2011 15:52, Ivan Calandra wrote: True, I didn't think about it because the matrix is supposed to be filled with 0 and 1, and I automatically thought about integers. It wouldn't be a problem with integers, right? If the matrix is really an integer matrix, right, otherwise not. Best,

Re: [R] delete rows whose sum is X

2011-03-04 Thread Ivan Calandra
True, I didn't think about it because the matrix is supposed to be filled with 0 and 1, and I automatically thought about integers. It wouldn't be a problem with integers, right? Le 3/4/2011 15:47, Uwe Ligges a écrit : On 04.03.2011 15:41, Ivan Calandra wrote: Oops, forgot one "=": mat[appl

Re: [R] delete rows whose sum is X

2011-03-04 Thread Uwe Ligges
On 04.03.2011 15:41, Ivan Calandra wrote: Oops, forgot one "=": mat[apply(mat, 1, FUN=function(x) sum(x)==5),] Yes, but since floating point issues may ba apparent in the end, I'd vote for: mat[apply(mat, 1, FUN = function(x) isTRUE(all.equal(sum(x), 5))),] Le 3/4/2011 15:36, Ivan Cal

Re: [R] delete rows whose sum is X

2011-03-04 Thread Ivan Calandra
Oops, forgot one "=": mat[apply(mat, 1, FUN=function(x) sum(x)==5),] Le 3/4/2011 15:36, Ivan Calandra a écrit : Hi Mikael You really need to provide a reproducible example in the future, it will help people to better understand what you want to do and help you, and help you better understand

Re: [R] delete rows whose sum is X

2011-03-04 Thread Ivan Calandra
Hi Mikael You really need to provide a reproducible example in the future, it will help people to better understand what you want to do and help you, and help you better understand the answers as well. Try something like this: mat[apply(mat, 1, FUN=function(x) sum(x)=5),] HTH, Ivan Le 3/4/2

Re: [R] delete rows whose sum is X

2011-03-04 Thread Sarah Goslee
On Fri, Mar 4, 2011 at 8:50 AM, purna wrote: > Rnoob here. > I have a matrix of zeroes ond ones. I want to delete the rows whose sum of > values is not =5, alternatively extract the rows who sum up to 5. > > Thank you/Mikael I think you would greatly benefit from reading some of the intro to R ma

[R] delete rows whose sum is X

2011-03-04 Thread purna
Rnoob here. I have a matrix of zeroes ond ones. I want to delete the rows whose sum of values is not =5, alternatively extract the rows who sum up to 5. Thank you/Mikael -- View this message in context: http://r.789695.n4.nabble.com/delete-rows-whose-sum-is-X-tp3335254p3335254.html Sent from th