-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 a ptype
argument to between()
#7073
Conversation
ptype
argument to between()
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.
Nice, thanks!
R/funs.R
Outdated
left <- args$left | ||
right <- args$right | ||
|
||
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.
These trailing spaces look odd, is this a setting in your editor?
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.
Not intentionally. I'm using Positron, which is still new to me.
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 think you have to opt in to "files.trimTrailingWhitespace": true,
in Positron settings, which we should probably considering automatically turning on in R files at least
I went ahead and fixed that up
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.
Looking good! I first made a few tweaks of my own before leaving these comments, so make sure to git pull
first before continuing your work to address these comments!
R/funs.R
Outdated
# But recycle to size of `x` | ||
args <- vec_recycle_common(!!!args, .size = vec_size(x)) | ||
# Recycle to size of `x` | ||
args <- vec_recycle_common(left = left, right = right, .size = vec_size(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.
If you do what we suggest above, then you can revert this part
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'm getting an error in my test when I try to revert.
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.
Error (test-funs.R:82:3): ptype argument works as expected with non-alphabetical ordered factors
Error in vec_recycle_common(!!!args, .size = vec_size(x))
: Can't splice an object of type because it is not a vector.
Backtrace:
▆
- ├─testthat::expect_identical(...) at test-funs.R:82:3
- │ └─testthat::quasi_label(enquo(object), label, arg = "object")
- │ └─rlang::eval_bare(expr, quo_get_env(quo))
- ├─dplyr::between(x, "c", "a", ptype = x)
- │ └─vctrs::vec_recycle_common(!!!args, .size = vec_size(x)) at dplyr/R/funs.R:55:3
- └─rlang::abort(message = message)
6347be6
to
7fc2123
Compare
7fc2123
to
132bda4
Compare
Thanks @JamesHWade! |
Fixes #6906
Add
ptype
argument tobetween()
functionThis PR introduces a new
ptype
argument to thebetween()
function, allowing users to specify the desired output type for comparisons. This enhancement is particularly useful when dealing with different data types or when specific type casting is required before comparison.Key changes:
ptype
parameter tobetween()
functionptype
for casting when providedptype
functionality