check_scalar_character()
checks whether the input is a character
scalar. If the input is not a character scalar, it raises an error message.
check_is_scalar_character()
returns TRUE
if the input is
a character scalar, and FALSE
otherwise.
Value
check_scalar_character()
: Returns the original value entered or raises an error message if the value is not a character scalar.check_is_scalar_character()
: Logical value,TRUE
if the value is a character scalar, andFALSE
otherwise.
Examples
# Examples for check_scalar_character()
# -------------------------------------
check_scalar_character("hello")
#> [1] "hello"
try(check_scalar_character(c("hello", "world")))
#> Error in check_scalar_character(c("hello", "world")) :
#> Expected 'char' to be a character scalar but got hello, world
check_scalar_character("single")
#> [1] "single"
try(check_scalar_character(123))
#> Error in check_scalar_character(123) :
#> Expected 'char' to be a character scalar but got 123
check_scalar_character("test")
#> [1] "test"
# Examples for check_is_scalar_character()
# ----------------------------------------
check_is_scalar_character("hello")
#> [1] TRUE
check_is_scalar_character(c("hello", "world"))
#> [1] FALSE
check_is_scalar_character("single")
#> [1] TRUE
check_is_scalar_character(123)
#> [1] FALSE
check_is_scalar_character("test")
#> [1] TRUE