filesstrings (version 2.0.1)

all_equal: A more flexible version of all.equal for vectors.

Description

If one argument is specified, check that all elements of that argument are equal. If two arguments of equal length are specified, check equality of all of their corresponding elements. If two arguments are specified, a of length 1 and b of length greater than 1, check that all elements of b are equal to the element in a. If two arguments are specified, a of length greater than 1 and b of 1, check that all elements of a are equal to the element in b.

Usage

all_equal(a, b = NULL)

Arguments

a

A vector, array or list.

b

Either NULL or a vector, array or list of length either 1 or length(a).

Value

TRUE if "equality of all" is satisfied (as detailed in 'Description' above) and FALSE otherwise.

Examples

Run this code
# NOT RUN {
all_equal(1, rep(1, 3))
all_equal(2, 1:3)
all_equal(1:4, 1:4)
all_equal(1:4, c(1, 2, 3, 3))
all_equal(rep(1, 10))
all_equal(c(1, 88))
all_equal(1:2)
all_equal(list(1:2))
# }

Run the code above in your browser using DataCamp Workspace