Re: [R] trouble understanding why ...=="NaN" isn't true

From: Andrew Yee <andrewjyee_at_gmail.com>
Date: Tue, 29 May 2007 18:39:35 -0400

Okay, it turns out that there were leading spaces, so that in the data, it was represented as " NaN", hence the expression =="NaN" was coming back as false.

Is there a way to find out preemptively if there are leading spaces?

Thanks,
Andrew

On 5/29/07, Andrew Yee <andrewjyee_at_gmail.com> wrote:
>
> I have the following data:
>
> > dataset[2,"Sample.227"]
> [1] NaN
> 1558 Levels: -0.000 -0.001 -0.002 -0.003 -0.004 -0.005 -0.006 -0.007 -
> 0.008 -0.009 ... 2.000
>
>
> However, I'm not sure why this expression is coming back as FALSE:
>
> > dataset[2,"Sample.227"]=="NaN"
> [1] FALSE
>
> Similarly:
>
> > dataset[2,"Sample.227"]==NaN
> [1] NA
>
>
> It seems that since "NaN" is represented as a character, this expression
> =="NaN" should be TRUE, but it's returning as FALSE.
>
> Thanks,
> Andrew
>

        [[alternative HTML version deleted]]



R-help_at_stat.math.ethz.ch 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 Tue 29 May 2007 - 22:43:44 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 30 May 2007 - 00:31:58 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.