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

version 2.0.0: na argument of read_tsv() does allow empty cells to be parsed with no missing values/NAs #1255

Closed
pfreese opened this issue Jul 30, 2021 · 1 comment
Labels
bug an unexpected problem or unintended behavior

Comments

@pfreese
Copy link

pfreese commented Jul 30, 2021

The na argument of readr::read_tsv() and related functions does not properly allow for a cell between two consecutive tabs ("\t\t") to be parsed as "" instead of NA.

df_w_empty_cell <- data.frame(name = c("ben", ""),
                              age = c(5, 10),
                              stringsAsFactors = FALSE)
# .tsv has contents:
# name  age
# ben   5
#       10
tsv_file <- "/tmp/df_w_empty_cell.tsv"
readr::write_tsv(df_w_empty_cell, tsv_file)

# > df_loaded
# A tibble: 2 x 2
# name    age
# <chr> <dbl>
# ben       5
# NA       10     <- This NA should be "".
df_loaded <- readr::read_tsv(tsv_file,
                             na = "NA")
@jimhester jimhester added the bug an unexpected problem or unintended behavior label Jul 30, 2021
@jimhester
Copy link
Collaborator

Thank you for opening the issue with a reproducible example!

This was a bug in read_tsv() with readr 2.0.0, it was not correctly passing the na argument down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants