Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save juanchiem/3e0aba102fb2d595d1a3629be2638264 to your computer and use it in GitHub Desktop.

Select an option

Save juanchiem/3e0aba102fb2d595d1a3629be2638264 to your computer and use it in GitHub Desktop.
dat <- readxl::read_excel("data/balcarce_clima.xlsx")
dat <- dat %>%
mutate(year = lubridate::year(date)) %>%
select(year, everything())
library(openxlsx)
your_df_list <- dat %>% split(dat$year)
wb <- createWorkbook()
for (i in 1:length(your_df_list)) {
addWorksheet(wb, sheetName=names(your_df_list[i]))
writeData(wb, sheet=names(your_df_list[i]), x=your_df_list[[i]]) # Note [[]]
}
saveWorkbook(wb, "data/meteo_eea.xlsx", overwrite = TRUE)
drive_upload(path = as_dribble("Meteo Balcarce"), "data/meteo_eea.xlsx", overwrite = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment