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

Ken Knoblauch ken.knoblauch at inserm.fr
Tue Jul 15 17:40:40 CEST 2008


Daren Tan <daren76 <at> hotmail.com> writes:
 > Any better solution than this ? 
> sum(strsplit("TCGGGGGACAATCGGTAACCCGTCT", "")[[1]] == "G")

Try

table(strsplit("TCGGGGGACAATCGGTAACCCGTCT", ""))

A C G T 
5 7 8 5 
 and get all 4 at once.

HTH

-- 
Ken Knoblauch
Inserm U846
Institut Cellule Souche et Cerveau
Département Neurosciences Intégratives
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr



More information about the R-help mailing list