-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add fct_reordern() (Fix #16) #220
base: main
Are you sure you want to change the base?
Conversation
The integration check is only in R 3.2, and it is that when running one of the new examples, the following error is generated:
Looking at historical documentation (https://www.rdocumentation.org/packages/base/versions/3.2.0/topics/order), |
fct_reordern(.f = f, A, B), | ||
factor(f, levels = c("D", "C", "A", "B")) | ||
) | ||
expect_equal( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the tests for decreasing = TRUE
because you are just testing the behaviour of an existing function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed except for one to confirm that interaction between the two works as decreasing sorting is an important behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That adds a dependency on dplyr — instead you'll need to implement a local version of desc()
inside the test, e.g. desc <- function(x) -xtfrm(x)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my education, I thought that since the dplyr call is in a test and dplyr is already in the DESCRIPTION Suggests field, I thought that this was OK. (Similarly, since I have it in the examples in the help, I thought that the same applied there.) I'm happy to implement that way, but my hope was that this would be simpler for the user (via help) and future maintainer (via tests) to use.
Whichever way you confirm, I'll update to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that I have addressed all comments in the update that is about to be committed.
@hadley, I think that I have addressed everything. |
FYI, I have re-updated to current main and fixed all CI issues (mainly the updated issue around pkgdown changes since this PR was originally proposed). |
Fix #16
@hadley, I saw what you meant in the #16 discussion about affecting the value and not just the levels. That is addressed here. Also, I removed the
.desc
argument. Since it was both simpler and potentially friendlier to the user to leave thedecreasing
argument frombase::order()
exposed (it doesn't have thedplyr
dependency to sort decreasing), I left that. And, I made the defaultmethod
"radix" so that it would work with a vector of values fordecreasing
(something that would annoy me whenever I forgot that I needed to set the method, and it seemed like a minor wart to add an argument directly).Anyway, let me know what you think and if I'm missing something else important.