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

Implicit vs explicit printing of problems #726

Closed
jennybc opened this issue Oct 26, 2017 · 3 comments
Closed

Implicit vs explicit printing of problems #726

jennybc opened this issue Oct 26, 2017 · 3 comments

Comments

@jennybc
Copy link
Member

jennybc commented Oct 26, 2017

We're reading an (intentionally) tricky file in via readr. We hadn't planned on anyone using read_table() or read_table2() and yet ... someone did. Their expectation that these functions would work supports the viewpoint in #717 (make read_table() behave like read.table()).

Anyway, there are many problems, which makes sense. But the printing of the problems during import vs. explicit print after the fact suggests there's a printing problem.

reprex::reprex_info()
#> Created by the reprex package v0.1.1.9000 on 2017-10-25

library(readr)
url <- "https://raw.githubusercontent.com/STAT545-UBC/STAT545-UBC.github.io/master/gapminderDataFiveYear_dirty.txt"
df <- read_table2(url)
#> Parsed with column specification:
#> cols(
#>   year = col_integer(),
#>   pop = col_double(),
#>   lifeExp = col_double(),
#>   gdpPercap = col_double(),
#>   region = col_character()
#> )
#> Warning in rbind(names(probs), probs_f): number of columns of result is not
#> a multiple of vector length (arg 1)
#> Warning: 326 parsing failures.
#> row # A tibble: 5 x 5 col     row   col  expected    actual expected   <int> <chr>     <chr>     <chr> actual 1   145  <NA> 5 columns 7 columns file 2   146  <NA> 5 columns 7 columns row 3   147  <NA> 5 columns 7 columns col 4   148  <NA> 5 columns 7 columns expected 5   149  <NA> 5 columns 7 columns actual # ... with 1 more variables: file <chr>
#> ... ................. ... ................................. ........ ................................. ...... ................................. .... ................................. ... ................................. ... ................................. ........ ................................. ...... .......................................
#> See problems(...) for more details.

problems(df)
#> # A tibble: 326 x 5
#>      row   col  expected    actual
#>    <int> <chr>     <chr>     <chr>
#>  1   145  <NA> 5 columns 7 columns
#>  2   146  <NA> 5 columns 7 columns
#>  3   147  <NA> 5 columns 7 columns
#>  4   148  <NA> 5 columns 7 columns
#>  5   149  <NA> 5 columns 7 columns
#>  6   150  <NA> 5 columns 7 columns
#>  7   151  <NA> 5 columns 7 columns
#>  8   152  <NA> 5 columns 7 columns
#>  9   153  <NA> 5 columns 7 columns
#> 10   154  <NA> 5 columns 7 columns
#> # ... with 316 more rows, and 1 more variables: file <chr>
@grighi
Copy link

grighi commented Nov 7, 2017

I'm getting (i think) the same printing problem parsing failure warning even with read_fwf:

Warning: 1 parsing failure.
row # A tibble: 1 x 5 col       row   col               expected actual        file expected     <int> <chr>                  <chr>  <chr>       <chr> actual 1 1047945   X12 no trailing characters   1 99 'pawg.data' file # A tibble: 1 x 5

@jimhester
Copy link
Collaborator

The printing issues look to be fixed in the devel version

library(readr)
url <- "https://raw.githubusercontent.com/STAT545-UBC/STAT545-UBC.github.io/master/gapminderDataFiveYear_dirty.txt"
df <- read_table2(url)
#> Parsed with column specification:
#> cols(
#>   year = col_double(),
#>   pop = col_double(),
#>   lifeExp = col_double(),
#>   gdpPercap = col_double(),
#>   region = col_character()
#> )
#> Warning: 326 parsing failures.
#> row col  expected    actual                                                                                                         file
#> 145  -- 5 columns 7 columns 'https://raw.githubusercontent.com/STAT545-UBC/STAT545-UBC.github.io/master/gapminderDataFiveYear_dirty.txt'
#> 146  -- 5 columns 7 columns 'https://raw.githubusercontent.com/STAT545-UBC/STAT545-UBC.github.io/master/gapminderDataFiveYear_dirty.txt'
#> 147  -- 5 columns 7 columns 'https://raw.githubusercontent.com/STAT545-UBC/STAT545-UBC.github.io/master/gapminderDataFiveYear_dirty.txt'
#> 148  -- 5 columns 7 columns 'https://raw.githubusercontent.com/STAT545-UBC/STAT545-UBC.github.io/master/gapminderDataFiveYear_dirty.txt'
#> 149  -- 5 columns 7 columns 'https://raw.githubusercontent.com/STAT545-UBC/STAT545-UBC.github.io/master/gapminderDataFiveYear_dirty.txt'
#> ... ... ......... ......... ............................................................................................................
#> See problems(...) for more details.

Created on 2017-12-07 by the reprex package (v0.1.1.9000).

@lock
Copy link

lock bot commented Sep 25, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Sep 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants