Learn R Programming

tester (version 0.2.0)

is_scalar: Is scalar

Description

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

is_single_number

Examples

Run this code
is_scalar(1)  # TRUE
is_scalar(pi)  # TRUE
is_scalar(1:5)  # FALSE
is_scalar(matrix(runif(4), 2, 2))  # FALSE

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

is_positive_scalar(1.0)  # TRUE
is_positive_scalar(0)  # FALSE
is_positive_scalar(-10)  # FALSE
is_positive_scalar("hoskdflksfd")  # FALSE
is_positive_scalar(NA)  # FALSE

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

Run the code above in your browser using DataLab