sfirke/janitor

make_clean_names odd behavior with characters

tabauer23 opened this issue · 1 comments

Bug reports

odd behavior with make_clean_names() function (a la the clean_names()), not sure if it is intended, just me or a combination of both. I have a column name "FIrst Name" spelled with the capital FI in the original data name. I intended to use make_clean_names() in order to make it consistent with other similar data sets for merging purposes. I noticed when I used make_clean_names() however it produces a strange conversion.

Instead of the assumed 'first_name' the string becomes 'f_irst_name'. It adds extra underscores in the words.

# insert reprex here
make_clean_names('FIIIrst name')
# [1] "fii_irst_name"

make_clean_names("IIIII Name")
# [1] "iiiii_name"

make_clean_names("IIIIIName")
# [1] "iiiii_name"

Not sure if this is intended, or documented some place I might have missed?

This is the intended behavior. The documentation is that it comes from snakecase::to_any_case, and reading that documentation, this behavior can be controlled by the parsing_option argument:

janitor::make_clean_names(c('FIIIrst name', "IIIII Name", "IIIIIName"))
#> [1] "fii_irst_name" "iiiii_name"    "iiiii_name_2"
janitor::make_clean_names(c('FIIIrst name', "IIIII Name", "IIIIIName"), parsing_option = 0)
#> [1] "fiiirst.name" "iiiii.name"   "iiiiiname"

Created on 2023-01-26 with reprex v2.0.2