Re: [R] position of a specific character

2008-07-15 Thread Prof Brian Ripley
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 c

Re: [R] position of a specific character

2008-07-14 Thread Erik Iverson
gregexpr("\\(", frg) 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,

Re: [R] position of a specific character

2008-07-14 Thread Hua Li
finding the part: "(E:2.32,((G:0.67,J:0.67):0.44,H:1.11):1.21)" automatically! Thanks a lot! Hua --- On Mon, 7/14/08, Hua Li <[EMAIL PROTECTED]> wrote: > From: Hua Li <[EMAIL PROTECTED]> > Subject: [R] position of a specific character > To: "R-help&quo

[R] position of a specific character

2008-07-14 Thread Hua Li
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 t