Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

is.constant

is.constant


Description

A numerical vector consists only of identical values

Usage

is.constant(x)

Arguments

x

a vector

Value

TRUE if x is numerical and $\max(x) == \min(x)$.

Author(s)

Kjetil Brinchmann Halvorsen, kjetil@acelerate.com, expanded by Christian W. Hoffmann <christian.hoffmann@wsl.ch>

See Also

Examples

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

cwhmisc

Miscellaneous Functions for Math, Plotting, Printing, Statistics, Strings, and Tools

v6.6
GPL (>= 2)
Authors
Christian W. Hoffmann
Initial release
2018-08-24, 10:40:10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.