Tests if an object is a scalar number
is_scalar tests if an object is a scalar
is_not_scalar tests if an object is not a scalar
is_positive_scalar tests if an object is a positive scalar
is_negative_scalar tests if an object is a negative scalar

Arguments

x

an R object

See also

Examples

is_scalar(1)  # TRUE
#> [1] TRUE
is_scalar(pi)  # TRUE
#> [1] TRUE
is_scalar(1:5)  # FALSE
#> [1] FALSE
is_scalar(matrix(runif(4), 2, 2))  # FALSE
#> [1] FALSE

is_not_scalar(1:5)  # TRUE
#> [1] TRUE
is_not_scalar(NULL)  # TRUE
#> [1] TRUE
is_not_scalar(matrix(runif(4), 2, 2))  # TRUE
#> [1] TRUE

is_positive_scalar(1.0)  # TRUE
#> [1] TRUE
is_positive_scalar(0)  # FALSE
#> [1] FALSE
is_positive_scalar(-10)  # FALSE
#> [1] FALSE
is_positive_scalar("hoskdflksfd")  # FALSE
#> [1] FALSE
is_positive_scalar(NA)  # FALSE
#> [1] FALSE

is_negative_scalar(-1)  # TRUE
#> [1] TRUE
is_negative_scalar(0)  # FALSE
#> [1] FALSE
is_negative_scalar(10)  # FALSE
#> [1] FALSE
is_negative_scalar("hoskdflksfd")  # FALSE
#> [1] FALSE
is_negative_scalar(NA)  # FALSE
#> [1] FALSE