Last active
September 2, 2021 00:09
-
-
Save ddbs/3361eed5702b7a575682097c6d90ddeb to your computer and use it in GitHub Desktop.
Export dataframe/datatable groups to individual excel files
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(data.table) | |
data <- rio::import("compensation1.xls") | |
data <- janitor::clean_names(data) | |
colnames(data) | |
filename <- tools::file_path_sans_ext(file) #get filename sans extension or path | |
getwd() | |
slicer <- c("manager_first_name") | |
prefix <- c("") #end with _ | |
suffix <- c("") #start with _ | |
setDT(data) # convert the data into a data.table | |
data[, rio::export(.SD, paste0(filename, "_", prefix, .BY, suffix, ".xlsx")), by = slicer] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment