Learn R Programming

Tmisc (version 1.0.1)

are_all_equal: Are all equal?

Description

Are all the elements of a numeric vector (approximately) equal?

Usage

are_all_equal(x, na.rm = FALSE)

Value

Logical, whether all elements of a numeric vector are equal.

Arguments

x

A numeric vector.

na.rm

Remove missing values (FALSE by default; NAs in x will return NA).

Examples

Run this code
are_all_equal(c(5,5,5))
are_all_equal(c(5,5,5,6))
are_all_equal(c(5,5,5,NA,6))
are_all_equal(c(5,5,5,NA,6), na.rm=TRUE)
5==5.000000001
identical(5, 5.000000001)
are_all_equal(c(5L, 5, 5.000000001))

Run the code above in your browser using DataLab