[R] Cannot get "==" operator to return TRUE

G See gsee000 at gmail.com
Fri Feb 3 17:23:34 CET 2012


Thank you Duncan, that is very helpful.

Although I think we've got it sorted out now, to answer your previous
questions,  it is repeatable in a new R session, and the output of
charToRaw is below.

On Ubuntu, I get the following:
> charToRaw(x)
[1] 6e 2f 61 c2 a0

On Mac, I get:
> charToRaw(x)
[1] 6e 2f 61

Thanks to all for the help,
Garrett

On Fri, Feb 3, 2012 at 10:19 AM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 12-02-03 11:10 AM, G See wrote:
>>
>> Sorry, I meant
>> Do you know of a way to print a string such that I can see whether it
>> contains a *space* or a no-break space?
>
>
> Use tools::showNonASCII(x).  On Petr's example, it gives
>
> 1: n/a<c2><a0>
>
> Duncan Murdoch
>
>
>>
>>
>> On Fri, Feb 3, 2012 at 10:10 AM, G See<gsee000 at gmail.com>  wrote:
>>>
>>> Petr,
>>>
>>> Thank you!  That is great.
>>>
>>> Do you know of a way to print a string such that I can see whether it
>>> contains a string or a no-break space?
>>>
>>> Thanks,
>>> Garrett
>>>
>>> On Fri, Feb 3, 2012 at 10:01 AM, Petr Savicky<savicky at cs.cas.cz>  wrote:
>>>>
>>>> On Fri, Feb 03, 2012 at 09:25:10AM -0600, G See wrote:
>>>>>
>>>>> I have a data.frame named "df". The dput of df is at the bottom of this
>>>>> e-mail.
>>>>> What I'd like to do is replace the "n/a " values with NA.  On Mac OSX,
>>>>> it works
>>>>> to do this:
>>>>> df[df == "n/a"]<- NA
>>>>>
>>>>> However, it does not work on Ubuntu.  See below.
>>>>>
>>>>> Thanks in advance,
>>>>> Garrett
>>>>>
>>>>>> x<- df[27, 4] # complete data.frame dput is below
>>>>>> dput(x)
>>>>>
>>>>> "n/a "
>>>>
>>>>
>>>> Hi.
>>>>
>>>> This string contains a no-break space, not a space.
>>>>
>>>>  "n/a " == "n/a\uA0"
>>>>
>>>>  [1] TRUE
>>>>
>>>>  "n/a\uA0"
>>>>
>>>>  [1] "n/a "
>>>>
>>>> Hope this helps.
>>>>
>>>> Petr Savicky.
>>>>
>>>> ______________________________________________
>>>> 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.
>>
>>
>> ______________________________________________
>> 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.
>
>



More information about the R-help mailing list