How to Apply the all.equal Function in R (2 Examples)
This article demonstrates how to apply the all.equal function in R programming.
Creation of Example Data
vec1 <- 1:5 # Create example vectors in R vec1 # [1] 1 2 3 4 5 |
vec1 <- 1:5 # Create example vectors in R vec1 # [1] 1 2 3 4 5
vec2 <- 1:5 vec2 # [1] 1 2 3 4 5 |
vec2 <- 1:5 vec2 # [1] 1 2 3 4 5
vec3 <- c(1:4, 6) vec3 # [1] 1 2 3 4 6 |
vec3 <- c(1:4, 6) vec3 # [1] 1 2 3 4 6
Example 1: Apply all.equal() Function to Identical Vectors
all.equal(vec1, vec2) # Using all.equal() function # [1] TRUE |
all.equal(vec1, vec2) # Using all.equal() function # [1] TRUE
Example 2: Apply all.equal() Function to Different Vectors
all.equal(vec1, vec3) # Using all.equal() function # [1] "Mean relative difference: 0.2" |
all.equal(vec1, vec3) # Using all.equal() function # [1] "Mean relative difference: 0.2"