[R] counting number of "G" in "TCGGGGGACAATCGGTAACCCGTCT"

Riley, Steve Steve.Riley at pfizer.com
Tue Jul 15 19:28:35 CEST 2008


Daren,

Not sure if it is any easier, but another solution is:


code <- unlist(strsplit("TCGGGGGACAATCGGTAACCCGTCT",""))

length(grep("[G]",code)) 


Steve 


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Daren Tan
Sent: Tuesday, July 15, 2008 11:28 AM
To: r-help at stat.math.ethz.ch
Subject: [R] counting number of "G" in "TCGGGGGACAATCGGTAACCCGTCT"


Any better solution than this ? 
 
sum(strsplit("TCGGGGGACAATCGGTAACCCGTCT", "")[[1]] == "G")
_________________________________________________________________


	[[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.



More information about the R-help mailing list