OneBite.Dev - Coding blog in a bite size

check if two arrays are equal in R

Code snippet on how to check if two arrays are equal in R

all.equal(array1, array2)

This code will check if two arrays, array1 and array2, are equal by comparing the elements of both arrays. This code uses the all.equal() function provided by the R software. The all.equal() function returns a Boolean value (TRUE or FALSE) indicating whether the two arrays contain the same elements or not. In this case if both arrays contain the same elements, the result will be TRUE, else it will be FALSE. This makes it easy to determine whether two arrays are equal or not.

r