[R] convert characters into integers in a matrix

From: Manisha Brahmachary <mb3058_at_c2b2.columbia.edu>
Date: Tue, 10 Jun 2008 14:28:35 -0400


I will appreciate any suggestion for this simple problem. I have a matrix of characters "A", "P", "M".  

I want to convert those characters to integers 0,1, 1 respectively. I am using the following R statements:  


 exprs.new1 <- gsub("A",0,exprs.new)

 exprs.new2 <- gsub("M",1,exprs.new1)  

The replaced integers are stored as characters and I cannot find a way to convert the matrix to an integer matrix.  



        [[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 Tue 10 Jun 2008 - 20:36:33 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 Tue 10 Jun 2008 - 21:30:58 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