Skip to content

mutate(row_number(key)) differs from mutate(dplyr::row_number(key)) #2792

Description

@cuttlefish44

mutate(row_number(key)) isn't equivalent to mutate(rank(key, ties.method = "first")) and mutate(dplyr::row_number(key)). I feel it's a bug.


library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

data_frame(a = c("a", "b", "C")) %>% arrange(a)
#> # A tibble: 3 × 1
#>       a
#>   <chr>
#> 1     a
#> 2     b
#> 3     C

data_frame(a = c("a", "b", "C")) %>% mutate(rank(a, ties.method = "first"))
#> # A tibble: 3 × 2
#>       a `rank(a, ties.method = "first")`
#>   <chr>                            <int>
#> 1     a                                1
#> 2     b                                2
#> 3     C                                3

data_frame(a = c("a", "b", "C")) %>% mutate(row_number(a))
#> # A tibble: 3 × 2
#>       a `row_number(a)`
#>   <chr>           <int>
#> 1     a               2
#> 2     b               3
#> 3     C               1

data_frame(a = c("a", "b", "C")) %>% mutate(dplyr::row_number(a))
#> # A tibble: 3 × 2
#>       a `dplyr::row_number(a)`
#>   <chr>                  <int>
#> 1     a                      1
#> 2     b                      2
#> 3     C                      3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions