Skip to content

empty_fill option in make_clean_names #595

@sw-jakobgepp

Description

@sw-jakobgepp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions