Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Petr PIKAL
Hi I have original data for which sub(' +$', '', ...) did not work in Excel so I could try them again. > grep("\t", as.character(becva$V1[1])) integer(0) > grep("\n", as.character(becva$V1[1])) integer(0) and Jim's solutions work as expected > sub('[[:space:]]+$', '', becva$V1[1]) [1] "02.06.1

Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Joris Meys
Hi Petr, Matt may very well have been right. As I copied the dput from the mail, any white space is converted to spaces apparently. Still, it might be possible the white spaces in your original data are tabs or even newline characters. You can check that easily with grep("\t", as.character(becva$

Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Matt Shotwell
On Wed, 2010-06-02 at 09:22 -0400, Petr PIKAL wrote: > Hi > > > dput(bbb) > c("02.06.10 12:40 ", "02.06.10 12:00 ", "02.06.10 11:00 ", > "02.06.10 10:00 ", "02.06.10 09:00 ", "02.06.10 08:00 ", > "02.06.10 07:00 ", "02.06.10 06:00 ", "02.06.10 05:00 ", > "02.06.10 04:00 ", "

Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Petr PIKAL
Hi thanks. I am puzzled what was wrong. Now even sub(' +$', '', bbb[1]) works. I am checking water throughput in nearby river and copying data from internet. So I wonder if there was some change recently as during floods they update it in about 10 minutes interval. Regards Petr jim holtman

Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Joris Meys
sub("\\s+$", '', bbb,perl=T) does it for me. On Wed, Jun 2, 2010 at 3:22 PM, Petr PIKAL wrote: > Hi > > > dput(bbb) > c("02.06.10 12:40 ", "02.06.10 12:00 ", "02.06.10 11:00 ", > "02.06.10 10:00 ", "02.06.10 09:00 ", "02.06.10 08:00 ", > "02.06.10 07:00 ", "02.06.10 06:00 ", "0

Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread jim holtman
You had the wrong case on 'w' and the wrong expression with [:space:]'; see below > bbb <- c("02.06.10 12:40 ", "02.06.10 12:00 ", "02.06.10 11:00 ", + "02.06.10 10:00 ", "02.06.10 09:00 ", "02.06.10 08:00 ", + "02.06.10 07:00 ", "02.06.10 06:00 ", "02.06.10 05:00 ", + "02.06.10

Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Petr PIKAL
Hi > dput(bbb) c("02.06.10 12:40 ", "02.06.10 12:00 ", "02.06.10 11:00 ", "02.06.10 10:00 ", "02.06.10 09:00 ", "02.06.10 08:00 ", "02.06.10 07:00 ", "02.06.10 06:00 ", "02.06.10 05:00 ", "02.06.10 04:00 ", "02.06.10 03:00 ", "02.06.10 02:00 ", "02.06.10 01:00 ", "02.

Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Matt Shotwell
On Wed, 2010-06-02 at 08:07 -0400, Petr PIKAL wrote: > Dear all > > I encountered strange problem with regexpr replacement > > I made this character object > > str <- "02.06.10 12:40 " > > > str(str) > chr "02.06.10 12:40 " > > I read in an object which seems to be quite similar > >

Re: [R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Joris Meys
Could you provide us with dput(becva$V1[1])? Cheers Joris On Wed, Jun 2, 2010 at 2:07 PM, Petr PIKAL wrote: > Dear all > > I encountered strange problem with regexpr replacement > > I made this character object > > str <- "02.06.10 12:40 " > > > str(str) > chr "02.06.10 12:40 " > > I r

[R] regexpr mystery can not remove trailing spaces

2010-06-02 Thread Petr PIKAL
Dear all I encountered strange problem with regexpr replacement I made this character object str <- "02.06.10 12:40 " > str(str) chr "02.06.10 12:40 " I read in an object which seems to be quite similar > str(as.character(becva$V1)[1]) chr "02.06.10 12:40 " However I can not rem