[R] is.na behavior

Richard M. Heiberger rmh at temple.edu
Thu Nov 19 04:03:21 CET 2015


David,

Your answer begs the question.
What is the problem with non-(list or vector) of type language.
To my eye both expression(abcd) and call("mean") look like they have
non-missing values, hence I anticipated that they are not NA, and therefore
that is.na() would return FALSE without a warning.

On the html email, I turned that off years ago.  It looks like gmail
(who handles
my university's email accounts) turned it back on.  I just turned it off again.
I too find it very annoying to have to revisit setting changes that I
didn't make.
Thank you for letting me know.

Rich


On Wed, Nov 18, 2015 at 9:36 PM, David Winsemius <dwinsemius at comcast.net> wrote:
>
>> On Nov 18, 2015, at 5:54 PM, Richard M. Heiberger <rmh at temple.edu> wrote:
>>
>> What is the rationale for the following warning in R-3.2.2?
>>
>>> is.na(expression(abcd))
>> [1] FALSE
>> Warning message:
>> In is.na(expression(abcd)) :
>>  is.na() applied to non-(list or vector) of type ‘expression’
>
> Well, the R interpreter does think that this is not a list:
>
>> is.list(expression(abcd))
> [1] FALSE
>
>
>> methods(is.na)
>  [1] is.na,abIndex-method       is.na,denseMatrix-method
>  [3] is.na,indMatrix-method     is.na,nsparseMatrix-method
>  [5] is.na,nsparseVector-method is.na,sparseMatrix-method
>  [7] is.na,sparseVector-method  is.na.coxph.penalty*
>  [9] is.na.data.frame           is.na.numeric_version
> [11] is.na.POSIXlt              is.na.raster*
> [13] is.na.ratetable*           is.na.Surv
>
>
> So the rationale is probably the same as the rationale for this warning:
>
>> is.na(call("mean", 1:4))
> [1] FALSE FALSE
> Warning message:
> In is.na(call("mean", 1:4)) :
>   is.na() applied to non-(list or vector) of type ‘language'
>
>>       [[alternative HTML version deleted]]
>
>
> I’m somewhat puzzled at your use of HTML for an Rhelp posting. I thought you were a longtime R user?
>
> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
> David Winsemius
> Alameda, CA, USA
>



More information about the R-help mailing list