Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: vec_proxy_na() #1925

Open
khusmann opened this issue Apr 9, 2024 · 0 comments
Open

feature request: vec_proxy_na() #1925

khusmann opened this issue Apr 9, 2024 · 0 comments

Comments

@khusmann
Copy link

khusmann commented Apr 9, 2024

Hello, thanks for this awesome library!

I'm working on a package for working with "missing reason" data in R.

I'm experimenting with vctrs to see if I can build a generic Result<Value, MissingReason> type vector. The goal is for it to act like transparently like the value type, but store reasons for missing values as an attribute. In my early experimentation, I've come really close: https://github.com/khusmann/interlacer/blob/vctrs/R/interlaced.R

It's 99% of the way there, but it just has one little quirk: I want to be able to define what I consider to be a "missing value" for the vector.

Right now, as you know, vec_detect_missing() and friends all use vec_proxy_equal() to determine what is considered missing. This creates a problem for me because I want equality to test the equality of missing reasons (e.g. na("Reason 1") == na("Reason 1") && na("Reason 1") != na("Reason 2")), but then with its current behavior this means only rows missing values AND reasons are considered NA by vec_detect_missing().

I can sort of work around this by providing custom definitions for is.na(), but this is only a surface level fix (I want something that'd properly propagate into the tidyverse like tidyr::replace_na)

I want to propose a new proxy for this: vec_proxy_na(). By default, it'd just call vec_proxy_equal() (so it would be 100% backwards compatible), but then when overridden it would allow developers like me a hook into the missingness behavior of their vctrs.

That said, if there's an alternate way to hook into vec_detect_missing(), please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant