identical(x, y, num.eq = TRUE, single.NA = TRUE, attrib.as.set = TRUE, ignore.bytecode = TRUE, ignore.environment = FALSE, ignore.srcref = TRUE)
x, y | Any objects. |
num.eq | a logical value. If TRUE (the default), non-NA numbers are compared using the logical "==" comparison. If FALSE, non-NA numbers are compared using memory bitwise comparison. For example, if FALSE, "+0.0" and "-0.0" are not equal. |
single.NA | a logical value. If TRUE (the default), checks that all NAs or all NaNs of the same type are identical (from a concept point of view). If FALSE, memory-bitwise comparison is used to check whether all NAs or all NaNs are identical. For example, if FALSE, +NaN and -NaN are not equal. (NA and NaN are not equal, no matter the value of single.NA.) |
attrib.as.set | a logical value. If TRUE (the default), the attributes of x, y are treated as an as unordered set. If FALSE, the attributes are treated as vector objects and are recursively compared, in all respects. |
ignore.bytecode | This argument is not yet implemented. a logical value. If TRUE (the default), compiled functions compare equal to their non-compiled counterparts. |
ignore.environment | a logical value. If TRUE, do not compare the enclosing environments of functions (closures) when deciding whether the functions are identical or not. If FALSE (the default), otherwise identical functions will be considered different if they were created in different environments. |
ignore.srcref | a logical value. If TRUE (the default), do not compare the srcref attributes of functions. This attribute maps the parts of a function to locations in the source (text) file that originally defined the function. |
x <- 1 y <- x + 0.000000001 all.equal(x, y) # returns TRUE identical(x, y) # returns FALSEidentical(1.0/Inf, 1.0/-Inf) # returns TRUE identical(1.0/Inf, 1.0/-Inf, num.eq = FALSE) # returns FALSE
identical(+NaN, -NaN) # returns TRUE identical(+NaN, -NaN, single.NA = FALSE) # returns FALSE
identical(NaN, NA_real_, single.NA = FALSE) # returns FALSE identical(NaN, NA_real_) # returns FALSE
identical(as.symbol, as.name) # returns TRUE
man1 <- 1; man2 <- 1 attributes(man1)<-list(name = "Tom", weight = 123, birth = 1975) attributes(man2)<-list(birth = 1975, name = "Tom", weight = 123) identical(man1, man2) # returns TRUE identical(man1, man2, attrib.as.set = FALSE) # returns FALSE