[R] is.na behavior

David Winsemius dwinsemius at comcast.net
Thu Nov 19 03:36:22 CET 2015


> 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