Skip to content

Commit

Permalink
add new chart
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorfturner committed Sep 1, 2018
1 parent d61edfc commit 8cb6a74
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions report.Rmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Budget Summary"
author: "Taylor Turner"
date: "July 24, 2018"
date: "September 1, 2018"
output:
html_document:
keep_md: True
Expand Down Expand Up @@ -281,7 +281,8 @@ pos <- setnames(data.frame(catmarg$TRID, catmarg$MARGIN), c("TRID", "MARGIN")) %
unique()
net <- setnames(merge(pos, neg, by = "TRID", all = T), c("TRID", "posCount", "posMargin", "negCount", "negMargin")) %>%
net <- setnames(merge(pos, neg, by = "TRID", all = TRUE), c("TRID", "posCount", "posMargin", "negCount", "negMargin")) %>%
group_by(TRID) %>%
mutate(
netCount = posCount - negCount,
Expand All @@ -290,7 +291,6 @@ net <- setnames(merge(pos, neg, by = "TRID", all = T), c("TRID", "posCount", "po
netMargin = posMargin + negMargin
)
stdevcatmarg <- catmarg %>%
group_by(TRID) %>%
mutate(stdev = sd(MARGIN),
Expand Down Expand Up @@ -323,14 +323,13 @@ for (dayNum in unique(food$PERIOD)){
}
daySeq <- as.data.frame(dayNumSeqAll)
rm(dayNumSeqAll)
daySeq <- daySeq %>%
mutate(PERIOD = dayNumSeqAll) %>%
select(-dayNumSeqAll)
food <- merge(daySeq, food, by = 'PERIOD', all = TRUE)
rm(maxDayByPeriod, daySeq)
foodTrans <- hist %>%
filter(TRID == 'FTRID') %>%
Expand All @@ -350,10 +349,23 @@ secondfinalFood <- food %>%
secondfinalFood <- as.data.frame(secondfinalFood)
food <- merge(foodTrans, secondfinalFood, by = 'PERIOD', all = TRUE) %>%
food <- foodTrans %>%
filter(PERIOD == paste0(year(Sys.time()), ifelse(length(month(Sys.time())) == 1, paste0(0,month(Sys.time())), month(Sys.time()))))
curPeriodDaySeq <- maxDayByPeriod %>% filter(PERIOD == unique(food$PERIOD))
curPeriodDaySeq <- expand.grid(PERIOD = curPeriodDaySeq$PERIOD, dynm = seq(1, curPeriodDaySeq$maxDay))
curPeriodDaySeq[is.na(curPeriodDaySeq)] <- 0
food <- merge(curPeriodDaySeq, food, by = c('PERIOD', 'dynm'), all = TRUE)
food[is.na(food)] <- 0
food <- merge(food, secondfinalFood, by = 'PERIOD', all = TRUE) %>%
unique() %>%
filter(PERIOD == paste0(year(Sys.time()), ifelse(length(month(Sys.time())) == 1, paste0(0,month(Sys.time())), month(Sys.time())))) %>%
mutate(cumPerDiem = cumsum(perDiem), cumTrans = cumsum(sumTrans))
mutate(cumPerDiem = cumsum(perDiem), cumTrans = cumsum(sumTrans)) %>%
filter(PERIOD == paste0(year(Sys.time()), ifelse(length(month(Sys.time())) == 1, paste0(0,month(Sys.time())), month(Sys.time()))))
rm(catmarg)
```
Expand Down Expand Up @@ -536,6 +548,9 @@ rm(tmp)
```{r saving_projection}
ggplotly(ggplot(savingsRate) + geom_point(aes(x = PERIOD, y = savingrate), stat = "identity") + xlab("Period") + ylab("Savings Rate") + ggtitle("Actual Savings Rate by Period") + scale_y_continuous(breaks = seq(-.50,.90, by = .05)) + theme(legend.position="none") + theme(axis.text.x = element_text(angle = 90, hjust = 1)))
ggplotly(ggplot(savingsRate) + geom_point(aes(x = PERIOD, y = CREDIT), stat = "identity") + xlab("Period") + ylab("Savings Amount") + ggtitle("Actual Savings by Period") + scale_y_continuous(breaks = seq(0,100000, by = 1000)) + theme(legend.position="none") + theme(axis.text.x = element_text(angle = 90, hjust = 1)))
savingsRate[40:52,]
ggplotly(ggplot(savingsRate, aes(x = PERIOD, y = runbal)) + geom_bar(stat = "identity") + ggtitle("Actual Cumulative Savings") + theme(axis.text.x = element_text(angle = 90, hjust = 1)))
Expand Down

0 comments on commit 8cb6a74

Please sign in to comment.