[R] [ifelse] how to maintain a value from original matrix without probs?

From: Diogo André Alagador <mcnda839_at_mncn.csic.es>
Date: Fri, 31 Oct 2008 15:59:18 +0100


Dear all,  

I have a matrix with positive and negative values.
>From this I would like to produce 2 matrices:
1st - retaining positives and putting NA in other positions 2nd - retaining negatives and putting NA in other positions  

and then apply rowMeans for both.  

I am trying to use the function ifelse in the exemplified form: ifelse(A>0,A,NA)
but by putting A as a 2nd parameter it changes dimensions of the original object.  

I wonder if I can do this, as it seems not to difficult.  

thanks in advance

        [[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. Received on Fri 31 Oct 2008 - 16:44:34 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 31 Oct 2008 - 18:30:20 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