Skip to content

Subsetting [ tibble row with "0" seems buggy #1636

@eitsupi

Description

@eitsupi

It seems to behave unexpectedly or generate errors.

tbl <- tibble::tibble(a = 1:3)

tbl[as.character(0:1), ]
#> # A tibble: 2 × 1
#>       a
#>   <int>
#> 1     1
#> 2     1
tbl[as.character(-1:0), ]
#> # A tibble: 2 × 1
#>       a
#>   <int>
#> 1    NA
#> 2    NA
tbl[as.character(0:2), ]
#> # A tibble: 3 × 1
#> Error in `[<-`:
#> ! Assigned data `map(.subset(x, unname), vectbl_set_names, NULL)` must
#>   be compatible with existing data.
#> ✖ Existing data has 3 rows.
#> ✖ Assigned data has 2 rows.
#> ℹ Only vectors of size 1 are recycled.
#> Caused by error in `vectbl_recycle_rhs_rows()`:
#> ! Can't recycle input of size 2 to size 3.
tbl["0", ]
#> # A tibble: 1 × 1
#> Error in `[<-`:
#> ! Assigned data `map(.subset(x, unname), vectbl_set_names, NULL)` must
#>   be compatible with existing data.
#> ✖ Existing data has 1 row.
#> ✖ Assigned data has 0 rows.
#> ℹ Row updates require a list value. Do you need `list()` or `as.list()`?
#> Caused by error in `vectbl_recycle_rhs_rows()`:
#> ! Can't recycle input of size 0 to size 1.

Created on 2025-05-03 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorhelp wanted ❤️we'd love your help!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions