assertthat icon indicating copy to clipboard operation
assertthat copied to clipboard

support %in%

Open maxheld83 opened this issue 9 years ago • 1 comments

it would be nice if there were a built-in assertion to test whether some object is %in% another one (say, a list or vector etc). This might be common when there are several available options, to test whether the passed argument is permissible.

Currently, say assert_that(factor %in% colnames(results$loa)) is possible, but on error, gives the slightly uninformative

#$ Error: `%in%`(x = factor, table = colnames(results$loa)) is not TRUE

maxheld83 avatar Oct 29 '15 13:10 maxheld83

Yes, the same applies for the is.element function.

MalteThodberg avatar Feb 21 '16 14:02 MalteThodberg