From 65c85bf6957785e9d89b4c8d7fbe715d3b522bad Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Fri, 30 Jul 2021 14:44:20 -0400 Subject: [PATCH] Correctly pass all arguments in read_tsv Fixes #1254 Fixes #1255 --- NEWS.md | 2 ++ R/read_delim.R | 10 +++++++--- tests/testthat/test-read-csv.R | 7 +++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 4dc79814..06d8af3d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # readr (development version) +* `read_tsv()` now correctly passes the `quote` and `na` arguments to `vroom::vroom()` (#1254, #1255) + * `options(readr.show_col_types = FALSE)` now works as intended (#1250) * Avoid spurious byte compilation errors due to the programatically generated `spec_*()` functions. diff --git a/R/read_delim.R b/R/read_delim.R index df26698d..fd1c887a 100644 --- a/R/read_delim.R +++ b/R/read_delim.R @@ -357,15 +357,19 @@ read_tsv <- function(file, col_names = TRUE, col_types = NULL, col_select = {{ col_select }}, id = id, .name_repair = name_repair, - locale = locale, skip = skip, + n_max = n_max, + na = na, + quote = quote, comment = comment, skip_empty_rows = skip_empty_rows, trim_ws = trim_ws, - n_max = n_max, + escape_double = FALSE, + escape_backslash = TRUE, + locale = locale, guess_max = guess_max, - progress = progress, show_col_types = show_col_types, + progress = progress, altrep = lazy, num_threads = num_threads ) diff --git a/tests/testthat/test-read-csv.R b/tests/testthat/test-read-csv.R index b21640eb..56a7be00 100644 --- a/tests/testthat/test-read-csv.R +++ b/tests/testthat/test-read-csv.R @@ -362,3 +362,10 @@ test_that("read_csv works with single quotes in skipped lines (#945)", { expect_equal(nrow(x), 1) expect_equal(ncol(x), 5) }) + +test_that("read_tsv correctly uses the quote and na arguments (#1254, #1255)", { + x <- read_tsv(I("foo\tbar\n\"one baz\"\ttwo\nthree\t\n"), quote = "", na = character()) + + exepct_equal(x[[1]], c("\"one baz\"", "three")) + exepct_equal(x[[2]], c("two", "")) +})