Skip to content

Instantly share code, notes, and snippets.

@sebastianrothbucher
Created February 4, 2018 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastianrothbucher/119d070cf87d129331e8684c83e19a19 to your computer and use it in GitHub Desktop.
Save sebastianrothbucher/119d070cf87d129331e8684c83e19a19 to your computer and use it in GitHub Desktop.
Spreadsheet summaries to CSV and Shiny
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")
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