allequal: Test if two objects have the same elements

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/utils.R

Description

allequal tests if two objects have all the same elements, including whether they have NAs in the same place.

Usage

1
allequal(x, y)

Arguments

x

first object to compare

y

second object to compare

Details

Unlike all(x == y), allequal will return FALSE if either object is NULL. Does not check class types, so allequal will return TRUE in some cases where identical will return FALSE (e.g. if two objects are identical when coerced to the same class). allequal always retuns a logical value, so it can be used safely in if expressions.

Value

Returns TRUE if x and y exist and all elements are equal, FALSE if some elements are unequal. If there are NA values, returns TRUE if is.na(x) == is.na(y) and all other elements are equal. Returns FALSE if is.na(x) != is.na(y). Retuns FALSE if x or y (but not both) is NULL.

Author(s)

Stephanie Gogarten

See Also

identical, all, all.equal

Examples

1
2
3
4
x <- c(1,2,NA,4); y <- c(1,2,NA,4);
allequal(x, y) ## TRUE
allequal(1, as.integer(1)) ## TRUE
allequal(1, "1") ## TRUE

GWASTools documentation built on Nov. 8, 2020, 7:49 p.m.