On Mon, 14 Jul 2008, Erik Iverson wrote:
gregexpr("\\(", frg)
Better
gregexpr("(", frg, fixed=TRUE)
(there is no regular expression here), but in this case
which(unlist(strsplit(frg, "")) == "(")
is more efficient (especially if you want to do further manipulations on
the individual characters, as Hau Li's followup seems to require).
Hua Li wrote:
Hi All,
I'm wondering whether there is a quick way to know the position of a
specific charcater in a long character:
for example
frg="((D:41.04,I:41.04):45.05,(((E:2.32,((G:0.67,J:0.67):0.44,H:1.11):1.21)"
and I would like to know that the 1st, 2nd, 26th, 27th, 28th ...
character is "(", is there a quick way to do that?
Thanks!
Hua
______________________________________________ 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.
--
Brian D. Ripley, [EMAIL PROTECTED]
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________
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.