Skip to content

add_row changes column type in empty data frame #171

@atribe

Description

@atribe

When not using all name-value pairs during add_row on empty tbl_df the column types are being changed to lgl.

Example:

example.empty.df <- structure(list(id = integer(0),
                                   install_id = integer(0),
                                   port = integer(0), 
                                   db_name = character(0),
                                   complete_db = integer(0)),
                              .Names = c("id", "install_id", "port", "db_name", "complete_db"),
                              row.names = integer(0),
                              class = c("tbl_df", "tbl", "data.frame"))

example.empty.df
# A tibble: 0 × 5
# ... with 5 variables: id <int>, install_id <int>, port <int>, db_name <chr>, complete_db <int>

changed.classes <- example.empty.df %>% tibble::add_row(install_id = 5)
changed.classes
# A tibble: 1 × 5
     id install_id  port db_name complete_db
  <lgl>      <dbl> <lgl>   <lgl>         <lgl>
1    NA          5    NA      NA            NA

I expected the column classes to be retained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions