Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_row() silently converts factor to character vector #296

wibom opened this issue Aug 18, 2017 · 2 comments

add_row() silently converts factor to character vector #296

wibom opened this issue Aug 18, 2017 · 2 comments


Copy link

wibom commented Aug 18, 2017

mydata <- tibble(
     a = letters[1:3] %>% factor(),
     b = 1:3)

Adding a row at the bottom works as expected:

mydata %>% add_row(b = 4)
# A tibble: 4 x 2
       a     b
  <fctr> <dbl>
1      a     1
2      b     2
3      c     3
4     NA     4

But adding a row to the top silently converts mydata$a to a character vector:

 mydata %>% add_row(b = 4, .before = 1)
# A tibble: 4 x 2
      a     b
  <chr> <dbl>
1  <NA>     4
2     a     1
3     b     2
4     c     3
@krlmlr krlmlr closed this as completed in b14143b Aug 18, 2017
Copy link

krlmlr commented Aug 18, 2017

Thanks for reporting!

krlmlr added a commit that referenced this issue Aug 22, 2017
Bug fixes

- Values of length 1 in a `tibble()` call are recycled prior to evaluating subsequent arguments, improving consistency with `mutate()` (#213).
- Recycling of values of length 1 in a `tibble()` call maintains their class (#284).
- `add_row()` now always preserves the column data types of the input data frame the same way as `rbind()` does (#296).
- `lst()` now again handles duplicate names, the value defined last is used in case of a clash.
- Adding columns to zero-row data frames now also works when mixing lengths 1 and 0 in the new columns (#167).
- The `validate` argument is now also supported in `as_tibble.tbl_df()`, with default to `FALSE` (#278).  It must be passed as named argument, as in `as_tibble(validate = TRUE)`.


- `format_v()` now always surrounds lists with `[]` brackets, even if their length is one. This affects `glimpse()` output for list columns (#106).
- Factor levels are escaped when printing (#277).
- Non-syntactic names are now also escaped in `glimpse()` (#280).
- `tibble()` gives a consistent error message in the case of duplicate column names (#291).
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

No branches or pull requests

2 participants