-
Notifications
You must be signed in to change notification settings - Fork 979
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
Allow functions in setnames input #3703
Comments
Looks interesting to me. |
one could imagine a whole range of functions: lower, upper, proper, camelcase, snakecase ... |
Makes sense and should be relatively easy for the basic functionality. New functions (
|
Or we could simply tweak |
I was thinking the user would provide their own functions. The snakecase package already exists for a variety of casing options, thought it does depend on string(r/i). |
To be clear, I have two extensions in mind:
Full customization could be delegated to downstreams, or we could roll a few of our own for ubiquitous cases like those laid out here. Third way is to take the |
So I personally vote for just refer users to e.g. snakecase in the manual... (and we can always add the extension functions in the future if there're users request for it...) |
as for me I prefer old style setnames(dt, fun(names(dt))) |
But if you only want to change a subset of the names, you may need to define a separate variable above like while @smingerson 's idea is : setnames(dt, c('a','b'), fun) |
Below are two proposed enhancements to
setnames()
, contrasted with current alternatives. I think they coincide with data.table's desire to provide concise syntax. I'd be happy to work on a PR for either or both of these if you think they are worth adding.Created on 2019-07-13 by the reprex package (v0.2.1)
The text was updated successfully, but these errors were encountered: