Skip to content

as.character(as.col_spec()) fails for data frames with logical columns #1127

@natecobb

Description

@natecobb

Referencing #895 feature request, which notes that as.col_spec() in the development branch can be used to generate a short/text col spec for existing data frames:

This fails in the current HEAD branch for data frames with logical columns because col_to_short() is missing collector_logical = "l' (I don't see any other missing types):

switch(class(x)[[1]],

Reprex:

library(readr)

# This works
as.character(readr::as.col_spec(mtcars))
#> [1] "ddddddddddd"

# This fails
mtcars2 <- mtcars
mtcars2$gas_guzzler <- mtcars2$mpg < 15
as.character(readr::as.col_spec(mtcars2))
#> Error in vapply(x$cols, col_to_short, character(1)): values must be length 1,
#>  but FUN(X[[12]]) result is length 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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