Learn R Programming

cwhmisc (version 6.0)

is.constant: is.constant

Description

A numerical vector consists only of identical values

Usage

is.constant(x)

Arguments

x
a vector

Value

$\max(x) == \min(x)$.

See Also

identical, all.equal

Examples

Run this code
 is.constant(rep(c(sin(pi/2),1),10)) # TRUE
 x <- factor(c(1,1,NA))
 is.constant(x)            # FALSE because of NA
 is.constant(x[1:2])       # TRUE
 is.constant(c(1,1,NA))    # FALSE because of NA
 is.constant(c(1,1,2))     # FALSE
 is.constant(c(1,1,1))     # TRUE

Run the code above in your browser using DataLab