if_na_null.Rd
This function makes sure you know what to expect when evaluating uncertain results in an if-clause. In most cases, you should not use this function, because it can lump a lot of very different cases together, but it may have some use for fool-proofing certain if-clauses on formr.org, where a field in a survey may either not exist, be missing or have a value to check.
if_na_null(test, na = FALSE, null = FALSE)
test | condition. can only have length 0 or length 1 |
---|---|
na | returned if the condition has a missing value |
null | passed to ifelse |
#> [1] "go on"if ( if_na_null(testdf$test2 == 1) ) { print("not shown") } if ( if_na_null(testdf$test3 == 1) ) { print("not shown") } tryCatch({ if ( if_na_null(testdf2$test1 == 1) ) { print("causes error") } }, error = function(e) { warning(e) })#> Error in if_na_null(testdf2$test1 == 1): object 'testdf2' not found