vctrs
vctrs copied to clipboard
Implement `vec_all_complete()`
See https://github.com/r-lib/vctrs/pull/1428#issuecomment-902130258
vec_drop_missing()would be useful invec_interleave()https://github.com/r-lib/vctrs/pull/1448/files#diff-8cc239533824402ee3430f8e3e98acb4e6c21a0aacad4bd0063b26de583a9e79R43vec_slice_complete()is a nicena.omit()replacement
I now feel somewhat strongly that a more flexible API is:
vec_any_missing(x)
vec_all_complete(x)
vec_detect_missing(x) (vec_equal_na)
vec_detect_complete(x)
Which get combined like:
if (vec_any_missing(x)) {
x <- vec_slice(x, !vec_detect_missing(x))
}
if (!vec_all_complete(x)) {
x <- vec_slice(x, vec_detect_complete(x))
}
That way you only pay for the logical vector creation and the slicing if you detect any missing or incomplete values.
This also gives you the flexibility to do:
if (vec_any_missing(x)) {
abort("Can't have missing values")
}
list_drop_empty() is a special case that probably would have been better as list_detect_empty() and list_any_empty(). But it is too late for that (we can obviously make those functions with list_sizes()).
We already have vec_detect_complete(), vec_equal_na(), and vec_any_missing(), so the only thing we are missing here is vec_all_complete().