Skip to content

problems() not pulling up the exact text of a parsing failure #548

@kendonB

Description

@kendonB

The example:

library(tidyverse)
x <- tribble(
  ~unit, ~value,
  "a"  ,    "1",
  "b"  ,     "(NA)")
write_tsv(x, path = "test.tsv")

Now try and parse with the incorrect NA specification (in the real application it's not obvious exactly what represents NA).

new_x <- read_tsv("test.tsv",
                  na = "",
                  col_types = cols(
                      unit = col_character(),
                      value = col_number()
                    ))
file.remove("test.tsv")

problems(new_x)
# A tibble: 1 × 4
#     row   col expected actual
#   <int> <chr>    <chr>  <chr>
# 1     2 value a number       

I would have expected this to come up:

# A tibble: 1 × 4
#   row     col expected actual
# <int>   <chr>    <chr>  <chr>
# 1   2   value a number   (NA) 

Is this the expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions