lenses icon indicating copy to clipboard operation
lenses copied to clipboard

Our first user!

Open cfhammill opened this issue 5 years ago • 0 comments

@zsbuchwald noticed an opportunity to use lenses in of her analyses this morning! The task was renaming columns in a matrix:

df %>%
  setNames(c(names(.)[1], paste0("rel-", names(.)[-1])))

became the beautiful

df %>%
  over(names_l %.% indexes(-1), 
       ~ paste0("rel-", .))

EDIT: for completeness this can be done with dplyr as well

df %>%
  rename_at(vars(-1), funs(paste0("rel-", .))

cfhammill avatar Oct 15 '18 16:10 cfhammill