Re: [R] Re gular Expression help

2008-11-08 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote: Here are a few more solutions. x is the input vector of character strings. The first is a slightly shorter version of one of Wacek's. The next three all create an anonymous grouping variable (using sub, substr/gsub and strapply respectively) whose components are p

Re: [R] Re gular Expression help

2008-11-08 Thread Wacek Kusnierczyk
Wacek Kusnierczyk wrote: Gabor Grothendieck wrote: Here are a few more solutions. x is the input vector of character strings. The first is a slightly shorter version of one of Wacek's. The next three all create an anonymous grouping variable (using sub, substr/gsub and strapply

Re: [R] Re gular Expression help

2008-11-08 Thread Gabor Grothendieck
For the problem at hand I think I would use your solution which is both easily understood and fastest. On the other hand the tapply based solutions are coordinate free (i.e. no explicit mucking with indices) and readily generalize to more than 2 groups -- just replace [^pq] with [^pqr], say. On

Re: [R] Re gular Expression help

2008-11-08 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote: For the problem at hand I think I would use your solution which is both easily understood and fastest. On the other hand the tapply based solutions are coordinate free (i.e. no explicit mucking with indices) and readily generalize to more than 2 groups -- just

Re: [R] Re gular Expression help

2008-11-08 Thread Gabor Grothendieck
I suspect strapply is only relatively slow on short strings where it doesn't matter anyways since for long strings performance would likely be dominated by the underlying regexp operations. I know that users are using the package for very long strings since I once had to lift the 25,000 character

Re: [R] Re gular Expression help

2008-11-08 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote: I suspect strapply is only relatively slow on short strings where it doesn't matter anyways since for long strings performance would likely be dominated by the underlying regexp operations. I know that users are using the package for very long strings since I once

Re: [R] Re gular Expression help

2008-11-08 Thread Gabor Grothendieck
I'll see if I can speed it up if I get some time. I personally use it on relatively short strings where the low absolute time means that the higher relative time your comparisons show are not that important. On Sat, Nov 8, 2008 at 5:33 PM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: Gabor

[R] Re gular Expression help

2008-11-07 Thread Rajasekaramya
hi there I have a vector with a set of data.I just wanna seperate them based on the first p and q values metioned within the data. [1] chr10p15.3 /// chr3q29 /// chr4q35 /// chr9q34.3 [2] chr1q22-q24 [3] chr1q22-q24 [4]

Re: [R] Re gular Expression help

2008-11-07 Thread Peter Dalgaard
Rajasekaramya wrote: hi there I have a vector with a set of data.I just wanna seperate them based on the first p and q values metioned within the data. [1] chr10p15.3 /// chr3q29 /// chr4q35 /// chr9q34.3 [2] chr1q22-q24 [3] chr1q22-q24

Re: [R] Re gular Expression help

2008-11-07 Thread Wacek Kusnierczyk
Peter Dalgaard wrote: Rajasekaramya wrote: hi there I have a vector with a set of data.I just wanna seperate them based on the first p and q values metioned within the data. [1] chr10p15.3 /// chr3q29 /// chr4q35 /// chr9q34.3 [2] chr1q22-q24 [3]

Re: [R] Re gular Expression help

2008-11-07 Thread Wacek Kusnierczyk
Wacek Kusnierczyk wrote: Peter Dalgaard wrote: Rajasekaramya wrote: hi there I have a vector with a set of data.I just wanna seperate them based on the first p and q values metioned within the data. [1] chr10p15.3 /// chr3q29 /// chr4q35 /// chr9q34.3 [2] chr1q22-q24

Re: [R] Re gular Expression help

2008-11-07 Thread Wacek Kusnierczyk
Wacek Kusnierczyk wrote: Rajasekaramya wrote: hi there I have a vector with a set of data.I just wanna seperate them based on the first p and q values metioned within the data. [1] chr10p15.3 /// chr3q29 /// chr4q35 /// chr9q34.3 [2] chr1q22-q24

Re: [R] Re gular Expression help

2008-11-07 Thread Gabor Grothendieck
Here are a few more solutions. x is the input vector of character strings. The first is a slightly shorter version of one of Wacek's. The next three all create an anonymous grouping variable (using sub, substr/gsub and strapply respectively) whose components are p and q and then tapply is used