Skip to content

x[1,,drop = TRUE] should return a list #367

Description

@patperry

Currently tibble behavior with drop = TRUE is consistent with data.frame for extracting a single column, but not for extracting a single row:

library(tibble)
as_tibble(mtcars)[1, , drop = TRUE]
#> # A tibble: 1 x 11
#>     mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1  21.0  6.00   160   110  3.90  2.62  16.5     0  1.00  4.00  4.00
mtcars[1, , drop = TRUE]
#> $mpg
#> [1] 21
#> 
#> $cyl
#> [1] 6
#> 
#> $disp
#> [1] 160
#> 
#> $hp
#> [1] 110
#> 
#> $drat
#> [1] 3.9
#> 
#> $wt
#> [1] 2.62
#> 
#> $qsec
#> [1] 16.46
#> 
#> $vs
#> [1] 0
#> 
#> $am
#> [1] 1
#> 
#> $gear
#> [1] 4
#> 
#> $carb
#> [1] 4

The data.frame behavior makes more sense to me here, because it fits with the general pattern that if x is a matrix-like object, then x[1,,drop = TRUE] returns a vector-like object.

Related: #311

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions