Conversation
|
Thanks. One way to do this with rlang: args <- list(from = 1, to = 3, by = 0.5)
rlang::inject(seq(!!!args))
#> [1] 1.0 1.5 2.0 2.5 3.0Created on 2025-03-26 with reprex v2.1.1 |
|
Not sure about the reason of the failure, as it does not seem to be related to the new edit: actually maybe because we needed a dev version of roxygen 2 Found the following Rd file(s) with Rd \link{} targets missing package
anchors:
hms.Rd: vec_cast
Please provide package anchors for all Rd \link{} targets not in the
package itself and the base packages. |
krlmlr
left a comment
There was a problem hiding this comment.
Thanks, great. If we must use inject(), we can, but do we really have to?
R/hms.R
Outdated
| seq.hms <- function( | ||
| from = hms(1), | ||
| to = hms(1), | ||
| ...) { |
There was a problem hiding this comment.
Minor nit: we prefer single indent these days.
| seq.hms <- function( | |
| from = hms(1), | |
| to = hms(1), | |
| ...) { | |
| seq.hms <- function( | |
| from = hms(1), | |
| to = hms(1), | |
| ... | |
| ) { |
Is there a reason to not add by to the signature to avoid handling the dots?
There was a problem hiding this comment.
I refactored the code to have by in the signature and get rid of ... handling.
Co-authored-by: Kirill Müller <krlmlr@users.noreply.github.com>
Co-authored-by: Kirill Müller <krlmlr@users.noreply.github.com>
|
@krlmlr Let me know if you need anything else on this PR. |
| if (!is.null(by)) { | ||
| if (!(is_hms(by) || inherits(by, "difftime"))) { | ||
| abort(sprintf( | ||
| "`by` isn't of class `hms` or `difftime` (current class: `%s`).", | ||
| class(by)[1] | ||
| )) | ||
| } | ||
| by <- vec_cast(as_hms(by), numeric()) | ||
| return(hms(seq(from, to, by, ...))) | ||
| } | ||
|
|
||
| hms(seq(from, to, ...)) |
There was a problem hiding this comment.
Minor nitpick: if we check if (is.null(by)), the shortcut (immediate return) is much easier to follow.
@krlmlr: we had to use
bquoteto splice the parameters gathered in the...as we can't use!!!withseq. It seems quite daunting. Maybe you have something easier?Closes #117