[R] is.na behavior

William Dunlap wdunlap at tibco.com
Thu Nov 19 04:04:12 CET 2015


You can convert the expression to a list and use is.na on that:
   > e <- expression(1+NA, NA, 7, function(x)x+1)
   > is.na(as.list(e))
   [1] FALSE  TRUE FALSE FALSE
and you can do the same for a call object
   > is.na(as.list(quote(func(arg1, tag2=NA, tag3=log(NA)))))
                tag2  tag3
   FALSE FALSE  TRUE FALSE

However, what is your motivation for wanting to apply is.na to an expression?

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Wed, 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'
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list