[R] min(NA,"bla") != min("bla", NA)
Rolf Turner
rolf.turner at xtra.co.nz
Fri Sep 27 03:10:01 CEST 2013
On 09/27/13 11:07, Duncan Murdoch wrote:
> On 13-09-26 5:32 PM, Rolf Turner 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.
>
> I've just built a 3.0.1 version, and I definitely see the bug there.
> What do you get from these expressions?
>
> str(min(NA, "bla"))
> str(min("bla", NA))
> str(min(NA_character_, "bla"))
>
> I get
>
> > str(min(NA, "bla"))
> int NA
> > str(min("bla", NA))
> chr "bla"
> > str(min(NA_character_, "bla"))
> chr "bla"
>
> on both Windows and OSX R 3.0.1. After today's patch, I get
>
> chr NA
>
> for all three.
I get:
> str(min(NA, "bla"))
int NA
> str(min("bla", NA))
chr NA
> str(min(NA_character_, "bla"))
chr NA
Which looks to me to be as it should be. How come my system's so good
compared to others? :-)
cheers,
Rolf
More information about the R-help
mailing list