Skip to content

set_names with tripledot #316

Description

@holgerbrandl

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")

Activity

  1. holgerbrandl commented on May 17, 2017

    @holgerbrandl
    Author

    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") 
    
  2. added a commit that references this issue on Jan 10, 2025
    0607f9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions