Created
February 18, 2020 17:55
-
-
Save sharlagelfand/be7661e22214db8bb5caa82a204fa59a to your computer and use it in GitHub Desktop.
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
| divide_by_two <- function(x, call. = FALSE) { | |
| if(!is.numeric(x)) { | |
| stop("IT'S NOT NUMERIC", call. = call.) | |
| } else { | |
| x/2 | |
| } | |
| } | |
| divide_by_two(2) | |
| #> [1] 1 | |
| divide_by_two("dog") | |
| #> Error: IT'S NOT NUMERIC | |
| divide_by_two("dog", call. = TRUE) | |
| #> Error in divide_by_two("dog", call. = TRUE): IT'S NOT NUMERIC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment