I've just started running readxl's output through repair_names() so it stops producing tibbles with empty, NA, or duplicated column names 🎉.
But I noticed that tibble::repair_names() and readr are not consistent.
x <- list(1:3,
var2 = letters[1:3],
c(1, 2, 3) + 0.1,
var2 = letters[26:24])
names(x)[3] <- NA
tibble::repair_names(tibble::as_data_frame(x, validate = FALSE))
#> # A tibble: 3 × 4
#> V1 var2 V2 var21
#> <int> <chr> <dbl> <chr>
#> 1 1 a 1.1 z
#> 2 2 b 2.1 y
#> 3 3 c 3.1 x
readr::read_csv(",var2,,var2\n1,'a',1.1,'z'\n2,'b',2.1,'y'\n3,'c',3.1,'x'")
#> Warning: Missing column names filled in: 'X1' [1], 'X3' [3]
#> Warning: Duplicated column names deduplicated: 'var2' => 'var2_1' [4]
#> # A tibble: 3 × 4
#> X1 var2 X3 var2_1
#> <int> <chr> <dbl> <chr>
#> 1 1 'a' 1.1 'z'
#> 2 2 'b' 2.1 'y'
#> 3 3 'c' 3.1 'x'
Feature requests, some inspired by readr:
- Report what and where re: modifications
- Number wrt absolute column position, as opposed to relative within the missing names
- Separate the de-deduplicating suffix with something regex-friendly
- Use a double underscore as prefix for new names and separator in de-duplication, e.g.
__X1 and var2__1.
The first one is for a better interactive experience. Otherwise, aimed at programmatic work with tibbles that may have been subjected to name repair.
I've just started running readxl's output through
repair_names()so it stops producing tibbles with empty,NA, or duplicated column names 🎉.But I noticed that
tibble::repair_names()and readr are not consistent.Feature requests, some inspired by readr:
__X1andvar2__1.The first one is for a better interactive experience. Otherwise, aimed at programmatic work with tibbles that may have been subjected to name repair.