Look at Mint transaction data via R
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
## Load libraries | |
if (!require(readr)) { install.packages("readr") }; library(readr) | |
if (!require(magrittr)) { install.packages("magrittr") }; library(magrittr) | |
if (!require(dplyr)) { install.packages("dplyr") }; library(dplyr) | |
if (!require(tibbletime)) { install.packages("tibbletime") }; library(tibbletime) | |
if (!require(lubridate)) { install.packages("lubridate") }; library(lubridate) | |
if (!require(devtools)) { install.packages("devtools") }; library(devtools) | |
if (!require(shinyview)) { install_github("peterhurford/shinyview") }; library(shinyview) | |
## Load Mint transactions | |
trans <- read_csv("~/Downloads/transactions.csv") | |
## Parse it into dataframe | |
trans <- trans %>% | |
mutate(Date = as.Date(Date, "%m/%d/%Y")) %>% | |
arrange(Date) %>% | |
as_tbl_time(index = Date) %>% | |
filter_time("2018-01" ~ "2018-03") %>% # Change this the appropriate date range | |
mutate(moy = month(Date)) | |
## Look at amount by category by month | |
view_trans_by_month <- function(trans) { | |
trans %>% | |
filter(`Transaction Type` == "debit") %>% | |
select(Date, moy, Amount, Description, Category) %>% | |
distinct %>% | |
group_by(moy, Category) %>% | |
summarise(total = sum(Amount)) %>% | |
arrange(-moy) %>% | |
shiny_view | |
} | |
## Look at individual transactions | |
view_trans <- function(trans) { | |
trans %>% | |
filter(`Transaction Type` == "debit") %>% | |
select(Date, moy, Amount, Description, Category) %>% | |
distinct %>% | |
arrange(moy, Category) %>% | |
shiny_view | |
} | |
view_trans_by_month(trans) | |
view_trans(trans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment