setequal()
function in R Language is used to check if two objects are equal. This function takes two objects like Vectors, dataframes, etc. as arguments and results in TRUE or FALSE, if the Objects are equal or not.
Syntax: setequal(x, y)
Parameters:
x and y: Objects with sequence of items
Example 1:
x1 < - c( 1 , 2 , 3 , 4 , 5 , 6 )
x2 < - c( 1 : 6 )
x3 < - c( 2 , 3 , 4 , 5 , 6 )
setequal(x1, x2)
setequal(x1, x3)
|
Output:
[1] TRUE
[1] FALSE
Example 2:
data_x < - data.frame(x1 = c( 5 , 6 , 7 ),
x2 = c( 2 , 2 , 2 ))
data_y < - data.frame(y1 = c( 5 , 6 , 7 ),
y2 = c( 2 , 2 , 2 ))
setequal(data_x, data_y)
|
Output:
[1] TRUE
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
15 Jun, 2020
Like Article
Save Article