How to check that two variable are same in R

r

#1

I have created two variable and I want to know that how I can check that this two variable are similar or identical I want to know because if variable of large size then how I can check this are identical
for example

x<-2
y<-3

I know that they are not identical but I want to know how we can check this in R


#2

Hi @sid100158,

I am not exactly sure about your ques but are you trying for something like this:
.
Also in case you would like to save the result into a vector:

Hope this helps!!


#3

Use the identical function.

x <- 1:30
y <- 1:30
identical(x,y)
--> TRUE
x <- 1:30
y <- 2:31
identical(x,y)
--> FALSE

#4

I personally usually make use of the duplicated-function:

x <- 1:30
y <- 1:30
z <- c(x,y)
table(duplicated(z))
y <- 31:60
z <- c(x,y)
table(duplicated(z))