The identical()
function in R is used to test if two given R objects are exactly equal.
identical(a, b)
The identical()
function takes the parameter values a
and b
that represent the R objects to be compared.
Note: The
identical()
function can take two or more objects.
The identical()
function returns either a TRUE
or FALSE
.
# creating different R objects to be compareda <- c('Bar', 'Baz', 'Foo' );b <- c('Baz', 'Foo', 'Bar' );c <- c('Bar', 'Baz', 'Foo' );d <- c('Bar', 'Baz', 'Foo', 'Foo', 'Foo');# checking if a and b are equalidentical(a, b)# checking if a and c are equalidentical(a, c)# checking if a, and d are equalidentical(a, d)
a
, b
, c
and d
for comparison.a
and b
are equal using the identical()
function.a
and c
are equal using the identical()
function.a
and d
are equal using the identical()
function.