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
vec2 <- 1:5
vec2
# [1] 1 2 3 4 5
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

Example 2: Apply all.equal() Function to Different Vectors

all.equal(vec1, vec3)        # Using all.equal() function
# [1] "Mean relative difference: 0.2"

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top