is_equal | R Documentation |
is_equal
tests if two vectors x
and y
are pairwise equal.
is_equal(x, y, ...)
x |
1st vector to compare (required). |
y |
2nd vector to compare (required). |
... |
Other parameters (passed to |
If both x
and y
are numeric,
is_equal
calls num_equal(x, y, ...)
(allowing for some tolerance threshold tol
).
Otherwise, x
and y
are compared by x == y
.
is_equal
is a safer way to verify the (near) equality of numeric vectors than ==
,
as numbers may exhibit floating point effects.
num_equal
function for comparing numeric vectors;
all.equal
function of the R base package;
near
function of the dplyr package.
Other numeric functions:
base2dec()
,
base_digits
,
dec2base()
,
is_wholenumber()
,
num_as_char()
,
num_as_ordinal()
,
num_equal()
Other utility functions:
base2dec()
,
base_digits
,
dec2base()
,
is_vect()
,
is_wholenumber()
,
num_as_char()
,
num_as_ordinal()
,
num_equal()
# numeric data:
is_equal(2, sqrt(2)^2)
is_equal(2, sqrt(2)^2, tol = 0)
is_equal(c(2, 3), c(sqrt(2)^2, sqrt(3)^2, 4/2, 9/3))
# other data types:
is_equal((1:3 > 1), (1:3 > 2)) # logical
is_equal(c("A", "B", "c"), toupper(c("a", "b", "c"))) # character
is_equal(as.Date("2020-08-16"), Sys.Date()) # dates
# as factors:
is_equal((1:3 > 1), as.factor((1:3 > 2)))
is_equal(c(1, 2, 3), as.factor(c(1, 2, 3)))
is_equal(c("A", "B", "C"), as.factor(c("A", "B", "C")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.