Learn R Programming

stratallo (version 3.0.1)

has_mixed_signs: Check for Mixed Signs in a Numeric Vector

Description

[Stable]

Determines whether a numeric vector contains both negative and positive values. Zero (0) is treated as neutral and does not count as either sign.

Usage

has_mixed_signs(x)

Value

TRUE if the vector contains both positive and negative values, FALSE otherwise.

Arguments

x

(numeric)
a vector to check.

Examples

Run this code
# internal functions (not exported) – examples skipped
if (FALSE) {
has_mixed_signs(1:5)
has_mixed_signs(-(1:5))
has_mixed_signs(c(-1, -2, 3))
has_mixed_signs(c(0, -1))
has_mixed_signs(c(0, 1))
has_mixed_signs(c(0, 1, -1))
}

Run the code above in your browser using DataLab