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: Allow fct_reorder to Work with Non-Numeric Results of .fun #147

Closed
billdenney opened this issue Sep 12, 2018 · 4 comments

Comments

@billdenney
Copy link
Contributor

commented Sep 12, 2018

This is the same issue as #103 with a different request.

It seems as though fct_reorder() and fct_reorder2() should only require that the results of the function are sortable not that they are numeric. Lexicographical order for the below is consistent and well-defined, but a simple numerical mapping can be more complex when the input isn't as simple as the below.

My feature request is: Can fct_reorder() and fct_reorder2() please allow non-numeric values? It seems like it could be as simple as running xtfrm() on the results of .fun.

Related to this, can the documentation be updated to indicate what the return value of .fun() must be?

library(forcats)
fct_reorder(.f=LETTERS[1:3], .x=LETTERS[4:6], .fun=min)
#> Error: `fun` must return a single number per group

Created on 2018-09-11 by the reprex package (v0.2.0).

@hadley

This comment has been minimized.

Copy link
Member

commented Jan 4, 2019

Seems reasonable to me.

billdenney added a commit to billdenney/forcats that referenced this issue Jan 4, 2019

@akgold

This comment has been minimized.

Copy link

commented Jan 19, 2019

Going to work on this for tidyverse dev day!

@billdenney

This comment has been minimized.

Copy link
Contributor Author

commented Jan 19, 2019

@akgold, I generated a PR for this several days ago (but it didn't link because I misunderstood how automatic linking between PR and issues worked-- titles don't link). Linked now.

@akgold

This comment has been minimized.

Copy link

commented Jan 19, 2019

@billdenney Ah, cool! Nevermind :)

@hadley hadley closed this in 13c06bc Feb 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.