Created
February 4, 2018 12:18
-
-
Save sebastianrothbucher/119d070cf87d129331e8684c83e19a19 to your computer and use it in GitHub Desktop.
Spreadsheet summaries to CSV and Shiny
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(readxl) | |
library(lubridate) | |
all <- NULL | |
for (fle in Filter(function(fle) grep("details_.+", fle), dir(pattern="*.xlsx"))) { | |
one <- as.data.frame(read_xlsx(fle, sheet="Summary", range="A2:D6", col_names=FALSE)) | |
colnames(one) <- c("Milestone", "Effort", "Due", "Stage") | |
one$Project <- sub("details_(.+)\\.xlsx", "\\1", fle) | |
all <- (if (!is.null(all)) rbind(all, one) else one) | |
} | |
all <- all[(!is.na(all$Milestone)),] | |
all$Due_month <- format(all$Due, '%Y-%m') | |
agg <- aggregate(Effort~Due_month, all, FUN=sum) | |
write.csv(all, file="all.csv") | |
write.csv(agg, file="agg.csv") |
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(readxl) | |
library(lubridate) | |
library(shiny) | |
all <- NULL | |
for (fle in Filter(function(fle) grep("details_.+", fle), dir(pattern="*.xlsx"))) { | |
one <- as.data.frame(read_xlsx(fle, sheet="Summary", range="A2:D6", col_names=FALSE)) | |
colnames(one) <- c("Milestone", "Effort", "Due", "Stage") | |
one$Project <- sub("details_(.+)\\.xlsx", "\\1", fle) | |
all <- (if (!is.null(all)) rbind(all, one) else one) | |
} | |
all <- all[(!is.na(all$Milestone)),] | |
all$Due_month <- format(all$Due, '%Y-%m') | |
agg <- aggregate(Effort~Due_month, all, FUN=sum) | |
shinyApp(ui = splitLayout( | |
tableOutput("tab"), | |
plotOutput("plt"), cellWidths=c('30%', '70%') | |
), server=function(input, output){ | |
output$tab <- renderTable(agg) | |
output$plt <- renderPlot(barplot(agg$Effort, names.arg=agg$Due_month)) | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment