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

From: Ken Knoblauch <ken.knoblauch_at_inserm.fr>
Date: Tue, 15 Jul 2008 15:40:40 +0000 (UTC)

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

______________________________________________
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 15 Jul 2008 - 15:43:32 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 15 Jul 2008 - 16:31:55 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