Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Created April 11, 2020 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yutannihilation/22559610919431bd3089b0377eac007d to your computer and use it in GitHub Desktop.
Save yutannihilation/22559610919431bd3089b0377eac007d to your computer and use it in GitHub Desktop.
library(readr)

bad_df1 <- readr::read_csv("a,b\n1,2\n-,2", col_types = "nn")
#> Warning: 1 parsing failure.
#> row col expected actual         file
#>   2   a a number      - literal data
bad_df2 <- readr::read_csv("a,b\n1,2\n2,-", col_types = "nn")
#> Warning: 1 parsing failure.
#> row col expected actual         file
#>   2   b a number      - literal data

dplyr::bind_rows(
  bad_df1,
  bad_df2
)
#> Error: Can't combine `..1` <spec_tbl_df<
#>   a: double
#>   b: double
#> >> and `..2` <spec_tbl_df<
#>   a: double
#>   b: double
#> >>.

attr(bad_df1, "problems") <- NULL
attr(bad_df2, "problems") <- NULL

dplyr::bind_rows(
  bad_df1,
  bad_df2
)
#> # A tibble: 4 x 2
#>       a     b
#> * <dbl> <dbl>
#> 1     1     2
#> 2    NA     2
#> 3     1     2
#> 4     2    NA

Created on 2020-04-11 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment