Re: [R] regexpr virtue

2009-07-29 Thread Petr PIKAL
nal Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Petr PIKAL > Sent: Wednesday, July 29, 2009 6:10 AM > To: r-h...@stat.math.ethz.ch > Subject: [R] regexpr virtue > > Hi all > > I have got something like that (act

Re: [R] regexpr virtue

2009-07-29 Thread Chuck Taylor
huck Taylor TIBCO Spotfire Seattle -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Petr PIKAL Sent: Wednesday, July 29, 2009 6:10 AM To: r-h...@stat.math.ethz.ch Subject: [R] regexpr virtue Hi all I have got something like that (actua

Re: [R] regexpr virtue

2009-07-29 Thread Gabor Grothendieck
dot means any character and * repeats it for as many times as possible so it replaces eveything (.*) up to the last dot (\\.) with nothing. On Wed, Jul 29, 2009 at 9:43 AM, Petr PIKAL wrote: > Thank you > > Gabor Grothendieck napsal dne 29.07.2009 > 15:20:40: > >> Here are a couple of possibiliti

Re: [R] regexpr virtue

2009-07-29 Thread Petr PIKAL
Thank you Gabor Grothendieck napsal dne 29.07.2009 15:20:40: > Here are a couple of possibilities: > > sub(".*\\.", "", s) This seems to be the target. Can you be so kind and translate for me what it really does? ".* matches several dots? \\. what is this? I thought sub finds a match and r

Re: [R] regexpr virtue

2009-07-29 Thread Petr PIKAL
Thanks If somebody does not come with more elaborated solution I will adapt yours. After strsplit I can get not only 3 but several chunks. If the last chunk is every time the one I need then sapply(strsplit(names(foto),"\\..."), length) [1] 2 6 6 6 6 5 5 6 5 3 3 3 3 3 3 3 3 3 3 4 3 3 4 4 3 3 3

Re: [R] regexpr virtue

2009-07-29 Thread Gabor Grothendieck
Here are a couple of possibilities: sub(".*\\.", "", s) library(gsubfn) strapply(s, "[0-9]*$", simplify = c) On Wed, Jul 29, 2009 at 9:10 AM, Petr PIKAL wrote: > Hi all > > I have got something like that (actually those are column names) > > [51] "X19.2.300b...80"          "X19.2.400v...80" "X

[R] regexpr virtue

2009-07-29 Thread Petr PIKAL
Hi all I have got something like that (actually those are column names) [51] "X19.2.300b...80" "X19.2.400v...80" "X19.2.400b...80" "X19.2.300v...90" "X19.2.300b...90" [56] "X19.2.400v...90" "X19.2..400b..90" "X19.2.300v...100" "X19.2.300b...100" "X19.2.400v