[R] puzzle using gsub (and encodings maybe)

2009-10-14 Thread Adrian Dragulescu
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]

Re: [R] puzzle using gsub (and encodings maybe)

2009-10-14 Thread Duncan Murdoch
On 10/14/2009 1:30 PM, Adrian Dragulescu wrote: 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 It looks as though it

Re: [R] puzzle using gsub (and encodings maybe)

2009-10-14 Thread Adrian Dragulescu
charToRaw(x) [1] 4e 45 57 20 59 4f 52 4b 20 ad 4e 45 57 20 45 4e 47 4c 41 4e 44 charToRaw(y) [1] 4e 45 57 20 59 4f 52 4b 20 2d 4e 45 57 20 45 4e 47 4c 41 4e 44 So they are different. Adrian I use R 2.8.1 on WinXP On Wed, 14 Oct 2009, Duncan Murdoch wrote: On 10/14/2009 1:30 PM,

Re: [R] puzzle using gsub (and encodings maybe)

2009-10-14 Thread Duncan Murdoch
On 10/14/2009 1:41 PM, Adrian Dragulescu wrote: charToRaw(x) [1] 4e 45 57 20 59 4f 52 4b 20 ad 4e 45 57 20 45 4e 47 4c 41 4e 44 charToRaw(y) [1] 4e 45 57 20 59 4f 52 4b 20 2d 4e 45 57 20 45 4e 47 4c 41 4e 44 So they are different. Adrian I use R 2.8.1 on WinXP But that's

Re: [R] puzzle using gsub (and encodings maybe)

2009-10-14 Thread Prof Brian Ripley
On Wed, 14 Oct 2009, Adrian Dragulescu wrote: charToRaw(x) [1] 4e 45 57 20 59 4f 52 4b 20 ad 4e 45 57 20 45 4e 47 4c 41 4e 44 charToRaw(y) [1] 4e 45 57 20 59 4f 52 4b 20 2d 4e 45 57 20 45 4e 47 4c 41 4e 44 So they are different. We really do need the 'at a minimum' information we asked

Re: [R] puzzle using gsub (and encodings maybe)

2009-10-14 Thread Adrian Dragulescu
I get the same results (not working) using R 2.9.2 and R.10.0 beta. Thank you for looking at this. On Wed, 14 Oct 2009, Duncan Murdoch wrote: On 10/14/2009 1:41 PM, Adrian Dragulescu wrote: charToRaw(x) [1] 4e 45 57 20 59 4f 52 4b 20 ad 4e 45 57 20 45 4e 47 4c 41 4e 44 charToRaw(y)

Re: [R] puzzle using gsub (and encodings maybe)

2009-10-14 Thread Duncan Murdoch
On 10/14/2009 2:16 PM, Adrian Dragulescu wrote: I get the same results (not working) using R 2.9.2 and R.10.0 beta. But it is working: the dash is an ad in x, not a 2d. You need to ask to substitute for the ad character, e.g. by spacelongdash - rawToChar(as.raw(c(0x20, 0xad)))

Re: [R] puzzle using gsub (and encodings maybe)

2009-10-14 Thread Adrian Dragulescu
Thank you. If I use gsub( \xad, -, x) [1] NEW YORK-NEW ENGLAND I get what I want. Adrian sessionInfo() R version 2.9.2 (2009-08-24) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United

Re: [R] puzzle using gsub (and encodings maybe)

2009-10-14 Thread Duncan Murdoch
On 10/14/2009 2:29 PM, Adrian Dragulescu wrote: Thank you. If I use gsub( \xad, -, x) [1] NEW YORK-NEW ENGLAND I get what I want. Right, that's simpler than what I suggested. Duncan Murdoch Adrian sessionInfo() R version 2.9.2 (2009-08-24) i386-pc-mingw32 locale: