[R] min(NA,"bla") != min("bla", NA)

Sarah Goslee sarah.goslee at gmail.com
Fri Sep 27 00:03:48 CEST 2013


Sorry Rolf, but it's not just Windows (though I completely understand
the urge to blame it):

R> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-redhat-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=C                 LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] cairoDevice_2.19


R> min(NA,"bla")
[1] NA
R> min("bla",NA)
[1] "bla"
R> min(c(NA,"bla"))
[1] NA
R> min(c("bla",NA))
[1] NA

Sarah

On Thu, Sep 26, 2013 at 5:32 PM, Rolf Turner <rolf.turner at xtra.co.nz> wrote:
>
> Just to add to the confusion, on my system I get NA --- which I understand
> to be
> the correct value --- from all of min(NA,"bla"), min("bla",NA),
> min(c(NA,"bla")), and
> min(c("bla",NA)).  When I append the argument na.rm=TRUE to each of the
> calls,
> I get "bla" from each.
>
> So, no bug in my system.
>
>> sessionInfo()
>> R version 3.0.1 (2013-05-16)
>> Platform: x86_64-unknown-linux-gnu (64-bit)
>>
>> locale:
>> [1] C
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods base
>>
>> other attached packages:
>> [1] misc_0.0-15
>>
>> loaded via a namespace (and not attached):
>> [1] tools_3.0.1
>
>
> Are the rest of youse guys using Windoze?  No wonder ....
>
>     cheers,
>
>     Rolf
>
> On 09/27/13 05:55, Duncan Murdoch wrote:
>>
>> On 26/09/2013 11:07 AM, Magnus Thor Torfason wrote:
>>>
>>> Just ran these two statements:
>>>
>>>   > min(NA,"bla")
>>> [1] NA
>>>
>>>   > min("bla", NA)
>>> [1] "bla"
>>>
>>> And then reran with explicit na.rm=FALSE
>>>
>>>   > min(NA,"bla", na.rm=FALSE)
>>> [1] NA
>>>
>>>   > min("bla", NA, na.rm=FALSE)
>>> [1] "bla"
>>
>>
>> This should be all fixed now (at least for min and max; it's possible some
>> of the other summary functions still have oddities). It's in R-devel, soon
>> r-patched.  All of the above examples should now give a character NA.
>>
>> Duncan Murdoch
>>

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list