Last active
December 30, 2020 17:44
-
-
Save mhoban/2bd9f6293658e9c563d54abd65f12bdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(readxl) | |
library(writexl) | |
# which file to mess with | |
xlfile <- "~/tmp/bookofthedead.xlsx" | |
sheets <- excel_sheets(xlfile) | |
xlsheets <- map(sheets,~{ | |
read_xlsx(xlfile,sheet=.x) | |
}) %>% set_names(sheets) | |
# which sheet to mess with | |
which_sheet <- "first sheet" | |
# add the new column | |
xlsheets[[which_sheet]] <- xlsheets[[which_sheet]] %>% | |
mutate(newcolumn = paste0("a new value plus ",seq(nrow(.)))) | |
# write the new file | |
write_xlsx(xlsheets,"~/tmp/bookofthedead2.xlsx",format_headers = FALSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment