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

Should vec_proxy_compare() have a fallback? #210

Closed
hadley opened this issue Feb 28, 2019 · 4 comments
Closed

Should vec_proxy_compare() have a fallback? #210

hadley opened this issue Feb 28, 2019 · 4 comments

Comments

@hadley
Copy link
Member

hadley commented Feb 28, 2019

It would be nice to be able to sort data frames containing list columns. Should vec_proxy_compare() return seq_along(x)? Or should it return NULL, and then failures would be communicated downstream?

@hadley
Copy link
Member Author

hadley commented Feb 28, 2019

This is needed for (e.g.) tidyr::crossing() and nesting() because (for historical reasons) these sort all columns.

hadley added a commit that referenced this issue Feb 28, 2019
Quick hack to unblock tidyr development. Needs fuller consideration in #210.
@lionel- lionel- added the compare label Mar 7, 2019
@DavisVaughan
Copy link
Member

For sorting list columns we have changed usage vec_proxy_compare(relax = TRUE) to instead use vec_proxy_order(). This "orders" list column elements by first appearance, which seemed reasonable.

@lionel-
Copy link
Member

lionel- commented Sep 12, 2022

@DavisVaughan We can now close this I think?

@DavisVaughan
Copy link
Member

Yea, to close the loop:

We have vec_proxy_order.list() that allows you to sort lists by first appearance of the elements. We still error on vec_proxy_compare.list(), because comparison is not defined.

vctrs:::vec_proxy_order.list
#> function(x, ...) {
#>   # Order lists by first appearance.
#>   # This allows list elements to be grouped in `vec_order()`.
#>   # Have to separately ensure missing values are propagated.
#>   out <- vec_duplicate_id(x)
#>   na <- vec_equal_na(x)
#>   out <- vec_assign(out, na, NA_integer_)
#>   out
#> }
#> <bytecode: 0x7fbcc78e38e8>
#> <environment: namespace:vctrs>

vctrs:::vec_proxy_compare.list
#> function(x, ...) {
#>   stop_unsupported(x, "vec_proxy_compare")
#> }
#> <bytecode: 0x7fbcc7a575c0>
#> <environment: namespace:vctrs>

Created on 2022-09-12 with reprex v2.0.2

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

No branches or pull requests

3 participants