From whuber at embl.de  Wed Sep  8 00:01:23 2010
From: whuber at embl.de (Wolfgang Huber)
Date: Wed, 08 Sep 2010 00:01:23 +0200
Subject: [Rd] as.character on NaN gives "NaN", is that intentional?
In-Reply-To: <4C869022.7070800@bht-berlin.de>
References: <4C8666EE.9030807@bht-berlin.de> <4C867077.5030607@gmail.com>
	<4C869022.7070800@bht-berlin.de>
Message-ID: <4C86B633.90204@embl.de>


Hi Ulrike

any set of three people will probably have five different opinions on 
this, but I can see that this makes sense:

NA - not available, not measured, not recorded
NaN - result of an arithmetic computation that lies outside of the real 
numbers; in that sense, "available".

However, this point of view then opens up the question why 'is.na(NaN)' 
is 'TRUE'.


	Best wishes
	Wolfgang

On 07/09/10 21:18, Ulrike Gr?mping wrote:
> Kevin,
>
> I wouldn't mind NaN (although it seems a bit strange, because you
> wouldn't expect a character to be a number), but I find it strange to
> get the character string "NaN". is.na(as.character(NaN)) returns FALSE,
> which is what I dislike.
>
> Best, Ulrike
>
> Kevin R. Coombes schrieb:
>> It seems to me that preserving information about the kind of number
>> (or not) present would be useful. I rather like the fact that
>> as.numeric(as.character(NaN))
>> and
>> as.numeric(as.character(Inf))
>> both work as the identity operator on numeric-like objects. (In this
>> context, note that both is.numeric(NaN) and is.numeric(Inf) both
>> return TRUE.) In your example, the character string "ee" does not
>> represent any number that I know about (at least in standard R).
>>
>> Kevin
>>
>> On 9/7/2010 11:23 AM, Ulrike Gr?mping wrote:
>>> Dear DevelopeRs,
>>>
>>> I am surprised about the outcome of the second command:
>>>
>>> str(as.character(as.numeric("ee"))) str(as.character(log(-1)))
>>>
>>> I would have expected a character NA. Is there an intention behind
>>> this behavior?
>>>
>>> Best, Ulrike
>>>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 


Wolfgang Huber
EMBL
http://www.embl.de/research/units/genome_biology/huber



[Rd] as.character on NaN gives "NaN", is that intentional?
Wolfgang Huber