Skip to content

between() doesn't work if x is Date and left and right are character #7702

@etiennebacher

Description

@etiennebacher

The docs of between() say:

This is a shortcut for x >= left & x <= right

However, between() doesn't work if x is Date and left and right are character, while <= and >= work:

library(dplyr, warn.conflicts = FALSE)
packageVersion("dplyr")
#> [1] '1.1.4.9000'

x <- as.Date("2010-01-02")
x >= "2010-01-01" & x <= "2010-01-04"
#> [1] TRUE

between(x, "2010-01-01", "2010-01-04")
#> Error in `between()`:
#> ! Can't combine `x` <date> and `left` <character>.

The "Details" section says:

x, left, and right are all cast to their common type before the comparison is made.

but maybe it's worth updating the first line or mention somewhere that characters and dates are not compatible?

Maybe related to r-lib/vctrs#967

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions