-
Notifications
You must be signed in to change notification settings - Fork 7
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
vec_between() #26
Comments
Love the immediate date support library(vctrs)
vec_between <- function(x, left, right) {
vec_compare(x, left) >= 0 & vec_compare(x, right) <= 0
}
vec_between(Sys.Date(), Sys.Date() - 1, Sys.Date() + 1)
#> [1] TRUE
# posixlt
lt <- as.POSIXlt(Sys.time())
vec_between(lt, lt - 1, lt + 1)
#> [1] TRUE
# dates and posixlt
vec_between(lt, Sys.Date() - 1, lt + 1)
#> [1] TRUE
suppressPackageStartupMessages(library(dplyr))
between(lt, lt - 1, lt + 1)
#> Error in between(lt, lt - 1, lt + 1): Not compatible with requested type: [type=list; target=double]. Created on 2018-12-18 by the reprex package (v0.2.1.9000) |
Food for thought: what about considering the exlusive cases with flags?
|
I think I'd prefer something like: 1:5 %>% between(2, 5, "[]")
1:5 %>% between(2, 5, "()")
1:5 %>% between(2, 5, "(]")
1:5 %>% between(2, 5, "[)") It's succinct and should be recognisable to most users. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hello, I was told in tidyverse/dplyr#5122 that this is the place to track when Thanks! |
I think vctrs has all the tools (vec_proxy_compare, ...) for a generic implementation of between, e.g.
Created on 2018-12-18 by the reprex package (v0.2.1.9000)
The text was updated successfully, but these errors were encountered: