Skip to content

Instantly share code, notes, and snippets.

@nilforooshan
Last active March 30, 2019 08:56
Show Gist options
  • Select an option

  • Save nilforooshan/e65a4617d477eead8c59cd858bb5b6c3 to your computer and use it in GitHub Desktop.

Select an option

Save nilforooshan/e65a4617d477eead8c59cd858bb5b6c3 to your computer and use it in GitHub Desktop.
R: Getting around the problem with is.integer

Getting around the problem with is.integer

is.integer(1)

[1] FALSE

A new function:

is.wholenumber <- function(x, tol = .Machine$double.eps^0.5) abs(x - round(x)) < tol

Example:

is.wholenumber(1)

[1] TRUE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment