[R] regexpr mystery can not remove trailing spaces

From: Petr PIKAL <petr.pikal_at_precheza.cz>
Date: Wed, 02 Jun 2010 14:07:43 +0200


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 remove trailing spaces from it

> sub(' +$', '', as.character(becva$V1[1]))

[1] "02.06.10 12:40 "
> sub(' +$', '', str)

[1] "02.06.10 12:40"
>

Do somebody have an idea what to do?

$version.string
[1] "R version 2.12.0 Under development (unstable) (2010-04-25 r51820)"

on Windows

Regards
Petr



R-help_at_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. Received on Wed 02 Jun 2010 - 12:11:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jun 2010 - 13:00:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive