Tell if a variable's value is undefined (NA or NULL); If yes, and it is required by the mzQC standard, we can raise an error.
Source:R/misc.R
isUndefined.Rd
You can pass multiple variable, which are all checked. If any of them is undefined, the function returns TRUE
Arguments
- s
A variable to be checked for NA/NULL
- ...
More variable to be checked
- verbose
If TRUE and 's' is NULL/NA, will print the name of the variable which was passed in
- context
An optional string will be using within a warning message, to ease tracking of where in the mzQC structure the undefined value occurs
Examples
isUndefined(NA) ## TRUE
#> Warning: Variable 'NA' is NA/NULL
#> [1] TRUE
isUndefined(NULL) ## TRUE
#> Warning: Variable 'NULL' is NA/NULL
#> [1] TRUE
isUndefined(NA, NULL) ## TRUE
#> Warning: Variable 'NA' is NA/NULL
#> Warning: Variable 'NULL' is NA/NULL
#> [1] TRUE
isUndefined("") ## FALSE
#> [1] FALSE
isUndefined("", NA) ## TRUE
#> Warning: Variable 'NA' is NA/NULL
#> [1] TRUE
isUndefined(NA, "") ## TRUE
#> Warning: Variable 'NA' is NA/NULL
#> [1] TRUE
isUndefined(1) ## FALSE
#> [1] FALSE
myVar = NA
isUndefined(myVar) ## TRUE, with warning "Variable 'myVar' is NA/NULL!"
#> Warning: Variable 'myVar' is NA/NULL
#> [1] TRUE