# Check if Two Objects are Equal in R Programming – setequal() Function

`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:

 `# R program to illustrate  ` `# the use of setequal() function  ` `    `  `# Vector 1  ` `x1 <``-` `c(``1``, ``2``, ``3``, ``4``, ``5``, ``6``)     ` `    `  `# Vector 2   ` `x2 <``-` `c(``1``:``6``)     ` ` `  `# Vector 3 ` `x3 <``-` `c(``2``, ``3``, ``4``, ``5``, ``6``)  ` `    `  `# Calling setequal() Function  ` `setequal(x1, x2)        ` `setequal(x1, x3)        `

Output:

``` TRUE
 FALSE
```

Example 2:

 `# R program to illustrate   ` `# the use of setequal() function  ` `   `  `# Data frame 1  ` `data_x <``-` `data.frame(x1 ``=` `c(``5``, ``6``, ``7``),      ` `                     ``x2 ``=` `c(``2``, ``2``, ``2``))  ` `   `  `# Data frame 2  ` `data_y <``-` `data.frame(y1 ``=` `c(``5``, ``6``, ``7``),         ` `                     ``y2 ``=` `c(``2``, ``2``, ``2``))  ` `   `  `# Calling setequal() Function ` `setequal(data_x, data_y)    `

Output:

``` TRUE
```

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.