R/spending_line_total.R

#' Display bar chart broken down by spending category
#' author Graham Place
#'
#' @param spending_frame A data frame with expenses information (including currency)
#' @param outputCurr desired output currency to display totals in
#' @export
spending_line_total <- function(spending_frame, outputCurr = "USD") {
  library(ggplot2)
  library(dplyr)
  spending_frame <- convert(spending_frame, outputCurr)

  withTotals<- aggregate(Output ~ Date, spending_frame, sum)
  withTotals$Rank <- rank(withTotals$Output)

  #Plot:
  ggplot(withTotals, mapping = aes(x = withTotals$Date, y = withTotals$Output)) +
    geom_line(stat = "identity") +
    labs(x = "Date", y = paste("Total Spending in", toupper(outputCurr)), title = paste("Spending Over Time in", toupper(outputCurr))) +
    guides(fill = FALSE)
}
grahamplace/curRency documentation built on May 17, 2019, 8:19 a.m.