Abbreviations is ignored when using snake case
alapo opened this issue · 2 comments
alapo commented
The abbreviations
function is ignored when using the default "snake" but functions using other naming nomenclatures (an example is shown below using "upper camel")
Using "upper_camel", the column stays named "ID"
library(magrittr)
tibble::tibble("ID" = c(1), "Column-2" = c(1)) %>%
janitor::clean_names("upper_camel", abbreviations = c("ID"))
# A tibble: 1 x 2
ID Column2
<dbl> <dbl>
1 1 1
But when using "snake" the column gets renamed to lower case "id"
library(magrittr)
tibble::tibble("ID" = c(1), "Column-2" = c(1)) %>%
janitor::clean_names("snake", abbreviations = c("ID"))
# A tibble: 1 x 2
id column_2
<dbl> <dbl>
1 1 1
Does anyone have any recommendations?
billdenney commented
This appears to be an issue in snakecase:
snakecase::to_any_case(
string=c("ID", "Column-2"),
case="snake",
abbreviations="ID"
)
#> [1] "id" "column_2"
snakecase::to_any_case(
string=c("ID", "Column-2"),
case="upper_camel",
abbreviations="ID"
)
#> [1] "ID" "Column2"
Created on 2021-02-12 by the reprex package (v1.0.0)
alapo commented
Lifesaver! thanks