Skip to content

as_tibble inconsistencies #447

@hadley

Description

@hadley
library(tibble)

# rows vs columns
as_tibble(c(x = 1, y = 2))
#> # A tibble: 2 x 1
#>   value
#> * <dbl>
#> 1     1
#> 2     2
as_tibble(list(x = 1, y = 2))
#> # A tibble: 1 x 2
#>       x     y
#>   <dbl> <dbl>
#> 1     1     2

# fills in names
as_tibble(c(1, 2))
#> # A tibble: 2 x 1
#>   value
#>   <dbl>
#> 1     1
#> 2     2
as_tibble(list(1, 2))
#> Error: Columns 1, 2 must be named.

# different scheme for missing names
as_tibble(t(1:2))
#> # A tibble: 1 x 2
#>      V1    V2
#>   <int> <int>
#> 1     1     2

I'd recommend that as_tibble() always treats inputs as columns as if you want rows, you can use enframe(). Related to #205

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions