Thank you very much for a very good and useful package that I've started to use after your tutorial in Aalborg!
One function I find handy is to check wether a string matches a column name in a data.frame. I now use this function:
assert_is_col_name <- function(var, df) { assertive::assert_is_a_string(var) assertive::assert_is_of_length(var, 1) assertive::assert_is_subset(var, names(df)) }
Maybe that could be something to consider for the package?
Comments (3)
-
Account Deleted -
repo owner Hi Erik,
I'm glad that the package is useful for you. Note that
assert_is_a_string
already contains a check for the input having length 1 (it combinesassert_is_character
andassert_is_scalar
).I agree that using
is_subset
is a good way to check for the presence of columns. I'm not convinced that a whole new function is needed, but I've added this use case toexample(is_subset)
.Thanks for the feedback and idea.
-
repo owner - changed status to resolved
- Log in to comment