-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preserve decimals/periods? #258
Comments
I imagine this issue relates to Other possibility: @sfirke what do u think? Should we add the |
Yes, sorry this is for |
@Tazinho sorry to have let this sit, I just commented on #283 that it would be nice to support abbrevations and we could do that one, and this one, by taking your suggestion to pass more arguments through to |
I think that it makes sense to pass arguments on. I'll insert that in my next revisions to the clean_names rewrite. |
@Tazinho now that all of the E.g., a column named I don't see anything else to be done on the janitor side but it would be great to resolve this issue by showing how if at all it can be done via the snakecase options, or noting that it can't. |
Hi @sfirke this can be done via > make_clean_names(string, sep_in = "[^[:alnum:]|(?<!\\d)\\.]")
[1] "has_decimal2.3" I'd like to explain 1) what it does and 2) why it is a bit more complicated then one might initially assume...
|
I'd hesitate to use this solution because I think (without testing) that it
will break some more common cases. My guess is that a better solution
would be to work on this through the replacement path and have a default of
periods replaced with underscores. The issue with that is that punctuation
is replaced by regexp, and periods are conceptually different than other
punctuation, but it would be hard to separate them out.
|
The replacement path would also involve regular expressions. So I don't see a big difference. As the "replacement path" and the > make_clean_names(string, replace = c("[^[:alnum:]|(?<!\\d)\\.]" = "."), sep_in = NULL)
[1] "has_decimal2.3abc" It's certainly an option to move the "\." replacement as a default into the replace argument, but I don't think that this is an optimal path as it is in general a bit unfortunate to have this overlaping arguments. (I am not sure if I should integrate at some point a replacement mechanism into snakecase, just to make all these options more convenient working together and allow a more compact inferface for janitor). |
Maybe I misunderstood. I would not want to add a new user-facing argument that is a regular expressions as that tends to add complexity for many users, and not everyone understands regular expressions. I'd say that given tight timelines for CRAN and a better solution may be available by integrating something into snakecase, let's punt this a bit longer. |
I should have been clearer, I think we can leave janitor::clean_names as is -- I just wanted to show if/how this can be done by the determined user facing this situation. For @jzadra but also anyone who ends up here via Google. I think @Tazinho's examples do that perfectly, thank you! So I will close this now as solved. |
Is there any way to preserve decimals/periods? On occasion I have column names from ACS data that have decimal numbers in them, and I would like to keep the periods as changing both the periods and the spaces to underscores produces some rather confusing names.
The text was updated successfully, but these errors were encountered: