[R] min(NA,"bla") != min("bla", NA)
Don McKenzie
dmck at u.washington.edu
Fri Sep 27 00:07:29 CEST 2013
I had the same outcome as Sarah on mac OSX 10.8. R 3.0.1
On Sep 26, 2013, at 3:03 PM, Sarah Goslee <sarah.goslee at gmail.com> wrote:
> 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
>
> ______________________________________________
> 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.
Don McKenzie
Research Ecologist
Pacific Wildland Fire Sciences Lab
US Forest Service
Affiliate Professor
School of Environmental and Forest Sciences
University of Washington
phone: 206-732-7824
dmck at uw.edu
More information about the R-help
mailing list