I could reproduce the issue by making an xlsx
file with decimal headers. You could use a regex to fix it up. The example below assumes that any time you have six zeroes (or nines, after looking at the linked issue) or more in a row after a number or decimal point, you want to discard everything from the zeroes/nines onward.
library(tibble)
library(stringr)
dat <-
structure(
list(
`1.1000000000000001` = c("a", "b", "c"),
`1.2` = c(1, 2, 3),
`2.1` = c("d", "e", "f"),
`2.2000000000000002` = c(4, 5, 6)
),
.Names = c("1.1000000000000001", "1.2", "2.1", "2.2000000000000002"),
class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA, -3L)
)
dat
#> # A tibble: 3 x 4
#> `1.1000000000000001` `1.2` `2.1` `2.2000000000000002`
#> <chr> <dbl> <chr> <dbl>
#> 1 a 1 d 4
#> 2 b 2 e 5
#> 3 c 3 f 6
names(dat) <- names(dat) %>%
str_replace("([.[:digit:]])[09]{6,}(\\d+?)",
"\\1")
dat
#> # A tibble: 3 x 4
#> `1.1` `1.2` `2.1` `2.2`
#> <chr> <dbl> <chr> <dbl>
#> 1 a 1 d 4
#> 2 b 2 e 5
#> 3 c 3 f 6