tidyverse / vroom

Fast reading of delimited files
https://vroom.r-lib.org
Other
621 stars 60 forks source link

`id` option allows duplicate column names, ignores `.name_repair` #536

Open khusmann opened 7 months ago

khusmann commented 7 months ago

By setting id to the name of one of the existing columns, I can get a tibble with duplicate column names (no matter what .name_repair is set to)

library(vroom)

vroom(I("a,hello\n1,2\n"), id="hello")
#> Rows: 1 Columns: 3
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> dbl (2): a, hello
#> 
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 1 × 3
#>   hello                                  a hello
#>   <chr>                              <dbl> <dbl>
#> 1 /tmp/RtmpH8sYId/file1d51aa48b8ce78     1     2
vroom(I("a,hello\n1,2\n"), id="hello", .name_repair="minimal")
#> Rows: 1 Columns: 3
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> dbl (2): a, hello
#> 
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 1 × 3
#>   hello                                  a hello
#>   <chr>                              <dbl> <dbl>
#> 1 /tmp/RtmpH8sYId/file1d51aa497bfadb     1     2
vroom(I("a,hello\n1,2\n"), id="hello", .name_repair="universal")
#> Rows: 1 Columns: 3
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> dbl (2): a, hello
#> 
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 1 × 3
#>   hello                                  a hello
#>   <chr>                              <dbl> <dbl>
#> 1 /tmp/RtmpH8sYId/file1d51aa50745bec     1     2