num_equal | R Documentation |
num_equal
tests if two numeric vectors x
and y
are pairwise equal
(within some tolerance value 'tol').
num_equal(x, y, tol = .Machine$double.eps^0.5)
x |
1st numeric vector to compare (required, assumes a numeric vector). |
y |
2nd numeric vector to compare (required, assumes a numeric vector). |
tol |
Numeric tolerance value.
Default: |
num_equal
is a safer way to verify the (near) equality of numeric vectors than ==
,
as numbers may exhibit floating point effects.
is_equal
function for generic vectors;
all.equal
function of the R base package;
near
function of the dplyr package.
Other numeric functions:
base2dec()
,
base_digits
,
dec2base()
,
is_equal()
,
is_wholenumber()
,
num_as_char()
,
num_as_ordinal()
Other utility functions:
base2dec()
,
base_digits
,
dec2base()
,
is_equal()
,
is_vect()
,
is_wholenumber()
,
num_as_char()
,
num_as_ordinal()
num_equal(2, sqrt(2)^2)
# Recycling:
num_equal(c(2, 3), c(sqrt(2)^2, sqrt(3)^2, 4/2, 9/3))
# Contrast:
.1 == .3/3
num_equal(.1, .3/3)
# Contrast:
v <- c(.9 - .8, .8 - .7, .7 - .6, .6 - .5,
.5 - .4, .4 - .3, .3 - .2, .2 -.1, .1)
unique(v)
.1 == v
num_equal(.1, v)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.