[R] puzzle using gsub (and encodings maybe)
Adrian Dragulescu
adrian_d at eskimo.com
Wed Oct 14 19:30:19 CEST 2009
Hello,
Below is some output that shows my issue.
I have a variable x that I read from a file (more on this below)
> x
[1] "NEW YORK NEW ENGLAND"
> gsub(" -", "-", x) # this does not work!
[1] "NEW YORK NEW ENGLAND"
> Encoding(x) # is x in a special encoding? no
[1] "unknown"
> y = "NEW YORK -NEW ENGLAND" # I type in variable y
> gsub(" -", "-", y) # and gsub works as expected
[1] "NEW YORK-NEW ENGLAND"
>
I'm sure the problem has to do with the way I read the variable x. But even if
I change the encoding for x to ASCII, I still cannot do the sub.
I get x by reading a pdf file with pdftotext so you will not be able to
replicate my issue.
Thanks for any suggestions,
Adrian
More information about the R-help
mailing list