allequal {GWASTools} | R Documentation

## Test if two objects have the same elements

### Description

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

### Usage

    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

    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

[Package GWASTools version 1.36.0 Index]