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

Rewrite between() with vctrs #6260

Merged
merged 4 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# dplyr (development version)

* `between()` has been rewritten to utilize vctrs. This means that it is no
longer restricted to just numeric and date-time vectors. Additionally, `left`
and `right` are no longer required to be scalars, they can now also be vectors
with the same length as `x`. Finally, `left` and `right` are now cast to the
type of `x` before the comparison is made. This last change means that you
can no longer make comparisons like `between(<int>, 0, 2.5)`, as `2.5` can't
be cast to integer without losing information. We recommend that you convert
the `<int>` vector to double before calling `between()` if you require this
(#6183, #6260).

* Joins have undergone a complete overhaul. The purpose of this overhaul is to
enable more flexible join operations, while also providing tools to perform
quality control checks directly in the join call. Many of these changes are
Expand Down
38 changes: 18 additions & 20 deletions R/funs.R
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
#' Do values in a numeric vector fall in specified range?
#' Detect where values fall in a specified range
#'
#' This is a shortcut for `x >= left & x <= right`, implemented
#' efficiently in C++ for local values, and translated to the
#' appropriate SQL for remote tables.
#' This is a shortcut for `x >= left & x <= right`, implemented for local
#' vectors and translated to the appropriate SQL for remote tables.
#'
#' @param x A numeric vector of values
#' @param left,right Boundary values (must be scalars).
#' @param x A vector
#' @param left,right Boundary values. Both `left` and `right` are recycled to
#' the size of `x` and are cast to the type of `x`.
#' @export
#' @examples
#' between(1:12, 7, 9)
#'
#' x <- rnorm(1e2)
#' x[between(x, -1, 1)]
#'
#' ## Or on a tibble using filter
#' # On a tibble using `filter()`
#' filter(starwars, between(height, 100, 150))
between <- function(x, left, right) {
if (!is.null(attr(x, "class")) && !inherits(x, c("Date", "POSIXct"))) {
warn("between() called on numeric vector with S3 class");
}
args <- list(left = left, right = right)
args <- vec_cast_common(!!!args, .to = x)
args <- vec_recycle_common(!!!args, .size = vec_size(x))
left <- args[[1L]]
right <- args[[2L]]

if (length(left) != 1) {
abort("`left` must be length 1")
}
if (length(right) != 1) {
abort("`right` must be length 1")
}
left <- vec_compare(x, left)
left <- left >= 0L

if (!is.double(x)) {
x <- as.numeric(x)
}
.Call(`dplyr_between`, x, as.numeric(left), as.numeric(right))
right <- vec_compare(x, right)
right <- right <= 0L

left & right
}

#' Cumulativate versions of any, all, and mean
Expand Down
14 changes: 7 additions & 7 deletions man/between.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 45 additions & 44 deletions revdep/README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
# Revdeps

## Failed to check (27)
## Failed to check (30)

|package |version |error |warning |note |
|:------------|:-------|:-----|:-------|:----|
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|CausalImpact |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|elbird |0.2.3 |1 | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|loon.ggplot |? | | | |
|loon.shiny |? | | | |
|NA |? | | | |
|vivid |? | | | |
|package |version |error |warning |note |
|:--------------|:-------|:-----|:-------|:----|
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|diproperm |0.2.0 |1 | | |
|NA |? | | | |
|elbird |0.2.3 |1 | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|NA |? | | | |
|loon.ggplot |? | | | |
|loon.shiny |? | | | |
|MarketMatching |? | | | |
|NA |? | | | |
|psychReport |3.0.1 |1 | | |
|TestDimorph |0.4.1 |1 | | |
|vivid |? | | | |

## New problems (11)
## New problems (9)

|package |version |error |warning |note |
|:------------------------------------|:-------|:------|:-------|:----|
|[comperes](problems.md#comperes) |0.2.5 |__+1__ | | |
|[dodgr](problems.md#dodgr) |0.2.13 |__+1__ | |2 |
|[exuber](problems.md#exuber) |0.4.2 |__+1__ | | |
|[lans2r](problems.md#lans2r) |1.1.0 |__+1__ | |1 |
|[MBNMAtime](problems.md#mbnmatime) |0.2.1 |__+1__ | |1 |
|[modeldb](problems.md#modeldb) |0.2.2 |__+1__ | | |
|[multicolor](problems.md#multicolor) |0.1.5 |__+1__ | |1 |
|[parsnip](problems.md#parsnip) |0.2.1 | |__+2__ |1 |
|[sfnetworks](problems.md#sfnetworks) |0.5.5 |__+2__ |__+1__ | |
|[stars](problems.md#stars) |0.5-5 |__+1__ | |1 |
|[Tplyr](problems.md#tplyr) |0.4.4 |__+1__ | | |
|package |version |error |warning |note |
|:----------------------------------|:-------|:--------|:-------|:----|
|[brolgar](problems.md#brolgar) |0.1.2 |__+1__ | | |
|[cubble](problems.md#cubble) |0.1.0 | |__+1__ | |
|[gmgm](problems.md#gmgm) |1.1.0 |__+1__ | | |
|[helda](problems.md#helda) |1.1.5 |__+1__ | |1 |
|[hgnc](problems.md#hgnc) |0.1.0 |__+1__ | | |
|[imfr](problems.md#imfr) |0.1.9.1 |1 __+1__ | | |
|[inti](problems.md#inti) |0.5.5 | |__+1__ | |
|[presenter](problems.md#presenter) |0.1.1 | |__+1__ |1 |
|[respR](problems.md#respr) |2.0.2 |__+2__ | | |

57 changes: 26 additions & 31 deletions revdep/cran.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,50 @@
## revdepcheck results

We checked 3317 reverse dependencies (3295 from CRAN + 22 from Bioconductor), comparing R CMD check results across CRAN and dev versions of this package.
We checked 3324 reverse dependencies (3302 from CRAN + 22 from Bioconductor), comparing R CMD check results across CRAN and dev versions of this package.

* We saw 11 new problems
* We failed to check 5 packages
* We saw 9 new problems
* We failed to check 8 packages

Issues with CRAN packages are summarised below.

### New problems
(This reports the first line of each new failure)

* comperes
* brolgar
checking tests ... ERROR

* dodgr
checking tests ... ERROR

* exuber
checking tests ... ERROR

* lans2r
checking tests ... ERROR

* MBNMAtime
checking tests ... ERROR
* cubble
checking re-building of vignette outputs ... WARNING

* modeldb
* gmgm
checking tests ... ERROR

* multicolor
checking tests ... ERROR
* helda
checking examples ... ERROR

* parsnip
checking Rd files ... WARNING
checking for unstated dependencies in examples ... WARNING
* hgnc
checking examples ... ERROR

* sfnetworks
* imfr
checking examples ... ERROR
checking tests ... ERROR

* inti
checking re-building of vignette outputs ... WARNING

* stars
checking tests ... ERROR
* presenter
checking re-building of vignette outputs ... WARNING

* Tplyr
* respR
checking examples ... ERROR
checking tests ... ERROR

### Failed to check

* CausalImpact (NA)
* elbird (NA)
* loon.ggplot (NA)
* loon.shiny (NA)
* vivid (NA)
* diproperm (NA)
* elbird (NA)
* loon.ggplot (NA)
* loon.shiny (NA)
* MarketMatching (NA)
* psychReport (NA)
* TestDimorph (NA)
* vivid (NA)
Loading