[R] "ACCTGMX" to "1223400" in R?

John1983 sandhya_prabhakaran at yahoo.com
Mon Jul 19 23:31:55 CEST 2010


Hi,

I am a newbie in R and was working on some DNA data represented as strings
of A,C,T and G (also wild-character like M and X). I use the Bioconductor
package in R. Currently I need to convert a string of the form "ACCTGMX" to
"1223400" i.e. A is replaced by 1, C with 2, T with 3, G with 4 and any
other character with a 0. I checked with 'replace' and also with a function
called 'copySubstitute' found in the Biobase package but this is only for
files. 
The data here is a string ("ACCTGMX" ) and we need to convert it to yet
another string ("1223400"). Now I use the strsplit function to split
"ACCTGM" into "A" "C" "C" "T" "G" "M" and then use 'which' to assign the
corresponding numbers. 
Is there a faster way to do this or some function I can make use of?

Please advice.

Thank you.
-- 
View this message in context: http://r.789695.n4.nabble.com/ACCTGMX-to-1223400-in-R-tp2294636p2294636.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list