[R] min(NA,"bla") != min("bla", NA)
arun
smartpink111 at yahoo.com
Thu Sep 26 17:40:45 CEST 2013
min(c(NA,"bla"),na.rm=FALSE)
[1] NA
> min(c("bla",NA),na.rm=FALSE)
[1] NA
A.K.
----- Original Message -----
From: Ista Zahn <istazahn at gmail.com>
To: arun <smartpink111 at yahoo.com>
Cc: Magnus Thor Torfason <zulutime.net at gmail.com>; R help <r-help at r-project.org>
Sent: Thursday, September 26, 2013 11:36 AM
Subject: Re: [R] min(NA,"bla") != min("bla", NA)
Hi A.K.,
On Thu, Sep 26, 2013 at 11:22 AM, arun <smartpink111 at yahoo.com> wrote:
> Hi,
> min(5,1)
> #[1] 1
>
>
> min(c(1,5))
> #[1] 1
> min(c(1,5))==min(c(5,1))
> #[1] TRUE
>
>
>
> min(c(NA,"bla"))
> #[1] NA
> min(c("bla",NA))
> #[1] NA
> min(c("bla",NA),na.rm=FALSE)
> #[1] NA
> min(c("bla",NA),na.rm=TRUE)
> #[1] "bla"
What is the point of this example? The OP's point was (I hope I am not
putting words in his mouth) that the documentation for ?min says
" If ‘na.rm’ is ‘FALSE’ an ‘NA’ value in any of the arguments will
cause a value of ‘NA’ to be returned, otherwise ‘NA’ values are
ignored."
but that appears not to be true:
min("bla", NA)
[1] "bla"
It's not clear to me how your example is relevant.
Best,
Ista
>
> A.K.
>
>
>
> ----- Original Message -----
> From: Magnus Thor Torfason <zulutime.net at gmail.com>
> To: "r-help at r-project.org" <r-help at r-project.org>
> Cc:
> Sent: Thursday, September 26, 2013 11:07 AM
> Subject: [R] min(NA,"bla") != min("bla", NA)
>
> 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"
>
>
> That seems wrong. Would this be considered a bug or is there a way to
> explain these results in a different way?
>
> Best,
> Magnus
>
> ps. Tested on R 3.0.1, 32 bit for Windows (as well as some older versions)
>
> ______________________________________________
> 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.
>
>
> ______________________________________________
> 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.
More information about the R-help
mailing list