[R] how to threshold a matrix

From: affy snp <affysnp_at_gmail.com>
Date: Sat, 15 Dec 2007 10:56:46 -0500


Dear list,

I have a matrix M (2500 rows and 9 columns). It looks like

2.2     0.1      2.6    3.6 ......
0.4     1.9      2.7    4.2......
1.8     2.5      4.3    2.2.......
.....................

If I want to do:

(1) if M[i,j]>=0.3, M[i,j]=1
(2) if M[i,j]<=-0.3, M[i,j]=-1
(3) Otherwise, M[i,j]=0

Is there a way to ceil and floor the data?

Thanks a lot!

Allen

        [[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 Sat 15 Dec 2007 - 16:00:15 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 Sat 15 Dec 2007 - 17:30:18 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.