Cleans up bad data table names by removing dots ".", spaces, and hyphens, replacing all with an underscore "_"
tidy_colnames(data)
data | data.frame or tibble |
---|
tib <- tibble::tibble("colname.1" = c(1:5), "colname 2" = LETTERS[1:5], "colname-3" = letters[26:22]) tidy_colnames(tib)#> # A tibble: 5 x 3 #> colname_1 colname_2 colname_3 #> <int> <chr> <chr> #> 1 1 A z #> 2 2 B y #> 3 3 C x #> 4 4 D w #> 5 5 E v