Skip to contents

A helper function to convert NA values or empty strings to NULL. Used to handle Shiny input default values which return NA or "" instead of NULL when the input field is empty. numericInput returns NA, textInput returns "".

Usage

na_to_null(x)

Arguments

x

A value that may be NA or an empty string.

Value

NULL if x is a single NA value or empty string, otherwise x unchanged.

Author

Jared Andrews

Examples

na_to_null(NA)
#> NULL
na_to_null("")
#> NULL
na_to_null(5)
#> [1] 5