Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAllow 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)