Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

isEmpty

Check whether a useable function argument was provided


Description

This is a simple utility to check whether a function argument is missing, NULL, or has only NAs.

Usage

isEmpty(arg)

Arguments

arg

A function argument

Value

Logical vector of length 1.

Examples

## 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)

MplusAutomation

An R Package for Facilitating Large-Scale Latent Variable Analyses in Mplus

v0.8
LGPL-3
Authors
Michael Hallquist [aut, cre], Joshua Wiley [aut], Caspar van Lissa [ctb], Daniel Morillo [ctb]
Initial release
2020-09-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.