lenses
lenses copied to clipboard
Our first user!
@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-", .))