Created
March 29, 2016 17:28
-
-
Save aammd/1dce9fb8aab4ee6eb308b8f222ce2fbe to your computer and use it in GitHub Desktop.
But does it have a decimal?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
has_decimal <- function(x){ (x - floor(x)) > 0 } | |
## from ?is.integer | |
is.wholenumber <- | |
function(x, tol = .Machine$double.eps^0.5) abs(x - round(x)) < tol | |
## from http://stackoverflow.com/questions/3476782/how-to-check-if-the-number-is-integer/3477158#3477158 | |
## from SO and also twitter https://twitter.com/polesasunder/status/700091075269005313 | |
is_whole <- function(x) x%%1==0 | |
## apparently this is rather fast | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment