is.equal | R Documentation |
Checks if two or more numerical values are identical within a relative numerical tolerance
is.equal(x, ..., stoptext = NULL, eps = sqrt(.Machine$double.eps))
x |
vector or array of values to compare |
... |
optional additional values to compare |
stoptext |
optional character string; if given, the routine stops if the values are not all equal and adds the character string to the error message |
eps |
relative numerical tolerance |
Returns a logical value. TRUE means that all values of x
are equal within the specified relative tolerance; also returns TRUE if all values are Inf or NA or NaN.
Danail Obreschkow
# almost identical values
x = c(acos(1/sqrt(2)),pi/4)
print(x)
print(x[1]==x[2])
print(is.equal(x))
# various other examples
print(is.equal(1,2,3))
print(is.equal(1,NA,3))
print(is.equal(Inf,NA))
print(is.equal(NaN,NA))
print(is.equal(NaN,Inf))
print(is.equal(Inf,Inf,Inf))
print(is.equal(NA,NA))
print(is.equal(NaN,NaN))
print(is.equal(1.4,1.4))
print(is.equal(1.4,1.400000001))
print(is.equal(1.4,1.400000001,1.41))
print(is.equal(0,0,0,0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.