Maybe the way to rephrase my question is to ask why there is not an is.na.expression method that does that task for me?
> is.na(as.list(expression("defg"))) [1] FALSE > is.na(expression("defg")) [1] FALSE Warning message: In is.na(expression("defg")) : is.na() applied to non-(list or vector) of type 'expression' > On Wed, Nov 18, 2015 at 10:22 PM, Richard M. Heiberger <r...@temple.edu> wrote: > It is in context of determining if an input argument for a graph title > is missing or null or na. In any of those cases the function defines > a main title. > If the incoming title is not one of those, then I use the incoming title. > When the incoming title is an expression I see the warning. > > library(lattice) > > simple <- function(x, y, main) { > if (missing(main) || is.null(main) || is.na(main)) > main <-"abcd" > xyplot(y ~ x, main=main) > } > > simple(1, 2) > simple(1, 2, main=expression("defg")) > > ## In the real case the constructed title is not a simple character > ## string, but the result of function call with several incoming > ## arguments and several computed arguments. It is of a complexity > ## that making it the default in the calling sequence would > ## unnecessarily complicate the calling sequence. > > On Wed, Nov 18, 2015 at 10:04 PM, William Dunlap <wdun...@tibco.com> wrote: >> 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 <r...@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@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. ______________________________________________ R-help@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.