Last active
August 29, 2015 14:27
-
-
Save jokergoo/4f21b81da6f5486ec206 to your computer and use it in GitHub Desktop.
This file contains 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
is_abs_unit <- function(x) UseMethod("is_abs_unit") | |
is_abs_unit.unit = function(x) { | |
unit = attr(x, "valid.unit") | |
if(unit %in% c(1:4, 7:24)) { | |
return(TRUE) | |
} else { | |
return(FALSE) | |
} | |
} | |
is_abs_unit.unit.list = function(x) { | |
all(sapply(x, is_abs_unit)) | |
} | |
is_abs_unit.unit.arithmetic = function(x) { | |
nm = names(x) | |
all(sapply(x, function(y) { | |
if(is.character(y)) TRUE | |
else if(is.null(y)) TRUE | |
else is_abs_unit(y) | |
})) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment