Skip to content
Prev 278730 / 398502 Next

Sum matrix by rows, conditional on value

On Nov 29, 2011, at 1:08 AM, Katrina Bennett wrote:

            
If you describe the meaning attached to the data if might help readers  
understand what the acceptable options might be. (Please read the  
Posting Guide.)
Are you hoping to subset particular rows?

If not, then you can make a copy and then set the negative values to NA

  thaw.mat <-cdem.mat.yr
  is.na(thaw.mat)<- thaw.mat < 0

and ...

  rowSums(thaw.mat, na.rm=TRUE)
I am guessing that your subset operation produced a vector and that  
apply or rowSums no longer makes any sense.
David Winsemius, MD
West Hartford, CT