R/trend_my_cc_debt.R

Defines functions trend_my_cc_debt

Documented in trend_my_cc_debt

#' Gets to debt by date
#' @param cc_spend_df spend dataframe from MASTER Credit Card Google Sheet
#' @importFrom magrittr %>%
#' @import dplyr
#' @import tidyverse
#' @importFrom reshape2 dcast
#' @importFrom somersaulteR mutate_rowsum
#' @importFrom somersaulteR impute_with_carry_forward
#' @export

trend_my_cc_debt <-
        function(cc_spend_df) {
                cc_data <- get_cc_data()

                x <-
                cc_data$SPEND %>%
                        reshape2::dcast(date ~ company + type, value.var = "balance", fun.aggregate = function(x) paste(x, collapse = " ")) %>%
                        dplyr::mutate_all(all_vars(na_if(., ""))) %>%
                        dplyr::mutate_at(vars(-(1)), as.numeric) %>%
                        somersaulteR::impute_with_carry_forward(dplyr::everything())

                somersaulteR::mutate_rowsum(x, 2:10)
        }
meerawhy/financeTracker documentation built on Dec. 3, 2019, 9:56 p.m.