Daren, Not sure if it is any easier, but another solution is:
code <- unlist(strsplit("TCGGGGGACAATCGGTAACCCGTCT","")) length(grep("[G]",code)) Steve -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daren Tan Sent: Tuesday, July 15, 2008 11:28 AM To: [EMAIL PROTECTED] Subject: [R] counting number of "G" in "TCGGGGGACAATCGGTAACCCGTCT" Any better solution than this ? sum(strsplit("TCGGGGGACAATCGGTAACCCGTCT", "")[[1]] == "G") _________________________________________________________________ [[alternative HTML version deleted]] ______________________________________________ R-help@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. ______________________________________________ R-help@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.