janitor icon indicating copy to clipboard operation
janitor copied to clipboard

empty_fill option in make_clean_names

Open sw-jakobgepp opened this issue 2 months ago • 0 comments

Hi, I wanted to clean a vector where empty strings should be kept as empty strings.

x <- c("A 1", NA, "")
janitor::make_clean_names(string = x, empty_fill = "")

[1] "a_1" "na"  "x"

The output is not what I expected it to be.

In the documentation, it is stated:

.. | Arguments passed on to snakecase::to_any_case empty_fill: A string. If it is supplied, then each entry that matches "" will be replaced by the supplied string to this argument.

I would have expected

[1] "a_1" "na"  ""

When I looked into the function, the internal problem is that the call to snakecase::to_any_case receives made_names, which is already pre-cleaned. Only when setting the option use_make_names = FALSE the parameter empty_fill triggers correctly.

janitor::make_clean_names(string = x, empty_fill = "", use_make_names = FALSE)

[1] "a_1" NA    ""

I think updating the documentation to make this clearer might help.

sw-jakobgepp avatar Oct 24 '25 07:10 sw-jakobgepp