Created
February 9, 2015 19:21
-
-
Save gmbecker/822900dac7a6a9a7f20f to your computer and use it in GitHub Desktop.
fancystopifnot
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
```{r} | |
fancystopifnot = function(obj, condfun) { | |
x = capture.output(str(obj)) | |
if(!condfun(obj)) stop(paste(c("Condition not met, got", x), | |
collapse = "\n\t"))} | |
fancystopifnot(data.frame(x = sample(1:100, 10), | |
y = sample(c("a", "b"), 10, replace=TRUE)), | |
is.integer) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like it!