Skip to content
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

set_names with tripledot #316

Closed
holgerbrandl opened this issue Apr 27, 2017 · 1 comment
Closed

set_names with tripledot #316

holgerbrandl opened this issue Apr 27, 2017 · 1 comment

Comments

@holgerbrandl
Copy link

@holgerbrandl holgerbrandl commented Apr 27, 2017

It would be great if set_names could support tripledots for the new names. Like

set_names <- function(df, ...){
    newnames <- as.character(unlist(list(...)))
    names(df) <- newnames;
    
    return(df)
}

This would allow even more streamlined coding without wrapping the names into another vector:

data %>% set_names("foo", "bar")
@hadley hadley closed this in 0607f9b May 3, 2017
@holgerbrandl
Copy link
Author

@holgerbrandl holgerbrandl commented May 17, 2017

Cool thanks. Btw this also helps outside of purrr to streamline dplyr pipes:

read_tsv("data.txt", col_names=F) %>% 
   select(4,5) %>% 
   set_names("foo", "bar") 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant