View source: R/utilityFunctions.R
isEmpty | R Documentation |
This is a simple utility to check whether a function argument is missing,
NULL
, or has only NA
s.
isEmpty(arg)
arg |
A function argument |
Logical vector of length 1.
## Not run:
f1 <- function(x) {
if (!isEmpty(x)) return(mean(x, na.rm = TRUE))
return(NULL)
}
f1() #> NULL
f1(x = NA) #> NULL
f1(x = NULL) #> NULL
f1(x = c(NA, 1:2)) #> 1.5
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.