Skip to content

Instantly share code, notes, and snippets.

@gmbecker
Created February 9, 2015 19:21
Show Gist options
  • Save gmbecker/822900dac7a6a9a7f20f to your computer and use it in GitHub Desktop.
Save gmbecker/822900dac7a6a9a7f20f to your computer and use it in GitHub Desktop.
fancystopifnot
```{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)
```
@jennybc
Copy link

jennybc commented Feb 10, 2015

I like it!

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