Introduction

For this personal data project, I am intending to draw insights by analyzing my credit card transactions. Due to the fast development of mobile transaction, spending money nowadays is more intangible to measure and conrol. So I feel it’s important for us to be more mindful about how to spend money, and this was a chance to visualize that. My plan was to collect my transaction data, clean it up, create visualizations in this dashboard, and use the graphs and data analysis to answer five questions about my spending trends.

To collect my data, I downloaded my transaction data through Year 2019 from January to December. The source is my online bank account, and it was surprisingly easy to get fairly clean datasets in CSV format.

Next let’s take a look at my data and my 5 questions.

Data variables

My five questions

  1. What are my spending distributions by category?
  2. What does my month-by-month spend look like?
  3. How often do I use my card each month?
  4. What do my typical purchases look like in terms of amount and category?
  5. What are some patterns in my Shopping expenses (No.1 Category of purchase)?

What are my spending distributions by category?


As you can see, Shopping, Dining(Food&Drink), Travel and Automotive are my 4 top-spending cateogires.

I was a little surprised to see shopping ranks number one since I have been cautious about not over purchasing. But I have to admit my consumer behabvior has been changing as time goes by since I care more about quality, brand and design than quantiry. So even though I don’t think I purchase larger amount of merchandise compared to previous year, I do admit I tend to purchase item with higher selling price which might give rise to the increase of total shopping amount.

It’s a little hard to believe that I spent nearly $4,000 on Food & Drink especially considering I cook a lot from time to time, which is around $330 each month.But when I dine out, I don’t usually control myself on how much I order or how expensive the food is. So in the future, I need to be cautious about ordering food and cook more oftern to eat healthy as well as saving money. Imagine if I can save 1/3 of my dining expenses and substitute with buying groceries and cook, how much money I can potentially save!

As for travelling, I am a big fan of it. So $3,000 per year for 4-5 small or big trips is still within reasonable range. But in the future, I want to use this similar amount of money doing more international trips.

A special expenses category showing here is automotive which is as high as nearly $3,000. My car warranty was expired so I have to pay everything out of my own pocket. Last year, I have several major car brokedowns such as brake replacement and burning oil, which were very costly. I don’t expect this pattern will last in the future but more a special occassion expense.

What does my month-by-month spend look like?


October is my highest spending month which is nearly twice or 3 times of the total expenses during other months, mainly due to fix the major car brokefown which costs nearly $4,000 one time. Besides October expense, spending on the rest months are not much off the track with comparatively more spending during summer season considering more outing activities which comes with higher cost.

It was very interesting for me to look at the changes in categories month to month. For example, Utilities and Gas stayed fairly constant, but I have been spending more and more in Beauty, and went crazy making Fashion purchases in June and August. These all make sense to me because makeup has become my hobby, and summer was the time I wanted to change my wardrobe to enjoy the summetime while making new purchase for the coming cold weather.

Note that because credit card transactions settle a few days after actually using the card, I don’t think plotting my data by Days of the Week would be accurate (but it’d be very interesting).

How often do I use my card each month?


Surprisingly, I made the most number of transactions in November, while my highest-spending month is October. Also, when comparing this line graph with my month-by-month dollar spend, I think in August and December I made fewer purchases but they were larger ones, whereas in November I made more transactions but ended up spending less than in either those 2 months. You can hover over the line graph to get the exact number of transactions each month.

What do my typical purchases look like in terms of amount and category?


I decided to use a scatterplot because it gives me a lot of information at a glance about my purchase behavior over time. I can see that my shoppingm, Food&Drink and Bills purchases tend to be larger in amount each time. Gas mainly consists of small purchases, but they are numerous.

Also, it looks like recently the only large purchase I made was for Food&Drink, since I was interested trying some high-end restaurant later last year. You can hover each dot to get more information about the purchase.

For Shopping, what is the spending by month in 2019? (my biggest spending category)


Shopping is my largest purchase category, so I am interested in to see how this category is like on a monthly basis.I noticed that the majority of my Shopping purchases are cosmetics and clothes. As you can tell, most purchase were happening during summer time and winter time when there was seasonal changes and the time of the year people went to outing more often either summer beach or winter sports. It is consistent with my life pattern but the inspiration for me is, for future better financial planning, before the peak shopping season arrives, I can plan ahead to know what are the main purchases I want to buy for this year, instead of randomly shopping in store or online which usually might end up spending more than I actually need.

---
title: "The Quantified Self - Final Project ANLY 512"
author: "Yining Jia"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    social: menu
    storyboard: true
    source: embed
    vertical_layout: fill
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)

#install.packages("ggplot2")

library(flexdashboard)
library(ggplot2)
library(tidyverse)
```


### Introduction

For this personal data project, I am intending to draw insights by analyzing my **credit card transactions**. Due to the fast development of mobile transaction, spending money nowadays is more intangible to measure and conrol. So I feel it's important for us to be more mindful about how to spend money, and this was a chance to visualize that. My plan was to collect my transaction data, clean it up, create visualizations in this dashboard, and use the graphs and data analysis to answer five questions about my spending trends.

To collect my data, I downloaded my transaction data through **Year 2019 from January to December**. The source is my online bank account, and it was surprisingly easy to get fairly clean datasets in CSV format.

Next let's take a look at my data and my 5 questions.

### Data variables
- Post_Date = Exact date the transaction was settled
- Month = Represented by number; e.g. April is 4
- Vendor
- Amount
- Category

### My five questions
1. What are my spending distributions by category?
2. What does my month-by-month spend look like?
3. How often do I use my card each month?
4. What do my typical purchases look like in terms of amount and category?
5. What are some patterns in my Shopping expenses (No.1 Category of purchase)?


### What are my spending distributions by category?

```{r}
boadata <- read.csv("Chasedata.csv", header=TRUE)

library(ggplot2)
p<- ggplot(boadata, aes(x = Category, y=Amount, fill=Category)) + 
  geom_bar(stat = "identity", fill = "Blue")+
  labs(title = "Spending per Category", x = "Category", y = "Amount") +
  coord_flip()
p

```

***
As you can see, Shopping, Dining(Food&Drink), Travel and Automotive are my 4 top-spending cateogires.

I was a little surprised to see shopping ranks number one since I have been cautious about not over purchasing. But I have to admit my consumer behabvior has been changing as time goes by since I care more about quality, brand and design than quantiry. So even though I don't think I purchase larger amount of merchandise compared to previous year, I do admit I tend to purchase item with higher selling price which might give rise to the increase of total shopping amount. 

It's a little hard to believe that I spent nearly $4,000 on Food & Drink especially considering I cook a lot from time to time, which is around $330 each month.But when I dine out, I don't usually control myself on how much I order or how expensive the food is. So in the future, I need to be cautious about ordering food and cook more oftern to eat healthy as well as saving money. Imagine if I can save 1/3 of my dining expenses and substitute with buying groceries and cook, how much money I can potentially save!

As for travelling, I am a big fan of it. So $3,000 per year for 4-5 small or big trips is still within reasonable range. But in the future, I want to use this similar amount of money doing more international trips. 

A special expenses category showing here is automotive which is as high as nearly $3,000. My car warranty was expired so I have to pay everything out of my own pocket. Last year, I have several major car brokedowns such as brake replacement and burning oil, which were very costly. I don't expect this pattern will last in the future but more a special occassion expense. 


### What does my month-by-month spend look like?

```{r}
#month <- ggplot(boadata, aes(x=Date, y=Amount)) + 
 # geom_line(color = "#00AFBB", size=2)+
  #labs(title = "Spend")

month <- ggplot(boadata, aes(x=Month, y=Amount)) +   
  geom_bar(aes(fill = Category),  stat="identity") +
  labs(title = "Spend by Month and Category", x = "Month", y = "Amount") +
  scale_x_continuous(breaks=c(1,2,3,4,5,6,7,8,9,10,11,12)) +
  theme(legend.position = "Right") +
  scale_fill_discrete(name="Category") +
  theme(legend.position = "right")

month

#month <- ggplot(boadata, aes(x=Date, y=Amount)) + 
  #geom_area(aes(color = "#00AFBB", fill="#00AFBB"),
                 #alpha = 0.5, position=position_dodge(0.8))

```

***
October is my highest spending month which is nearly twice or 3 times of the total expenses during other months, mainly due to fix the major car brokefown which costs nearly $4,000 one time. Besides October expense, spending on the rest months are not much off the track with comparatively more spending during summer season considering more outing activities which comes with higher cost. 

It was very interesting for me to look at the changes in categories month to month. For example, Utilities and Gas stayed fairly constant, but I have been spending more and more in Beauty, and went crazy making Fashion purchases in June and August. These all make sense to me because makeup has become my hobby, and summer was the time I wanted to change my wardrobe to enjoy the summetime while making new purchase for the coming cold weather.

Note that because credit card transactions settle a few days after actually using the card, I don't think plotting my data by Days of the Week would be accurate (but it'd be very interesting).


### How often do I use my card each month?
```{r}
library(plotly)
card <- ggplot(boadata, aes(x=Month)) +
  stat_count(geom='line', aes(y=..count..)) +
  labs(title = "Transactions", x = "Month", y = "Count")

(ggcard <- ggplotly(card))

```

***
Surprisingly, I made the most number of transactions in November, while my highest-spending month is October. Also, when comparing this line graph with my month-by-month dollar spend, I think in August and December I made fewer purchases but they were larger ones, whereas in November I made more transactions but ended up spending less than in either those 2 months. You can hover over the line graph to get the exact number of transactions each month.



### What do my typical purchases look like in terms of amount and category?

```{r}
boadata$Amount <- as.numeric(boadata$Amount)

purchases <- ggplot(boadata, aes(x = Post_Date, y = Amount)) +
  geom_point(aes(col=Category, size=Amount)) +
  labs(title = "My Purchases", x = "Date", y = "Amount")
 
(ggpurchases <- ggplotly(purchases))

```

***
I decided to use a scatterplot because it gives me a lot of information at a glance about my purchase behavior over time.  I can see that my shoppingm, Food&Drink and Bills purchases tend to be larger in amount each time. Gas mainly consists of small purchases, but they are numerous.

Also, it looks like recently the only large purchase I made was for Food&Drink, since I was interested trying some high-end restaurant later last year. You can hover each dot to get more information about the purchase.


### For Shopping, what is the spending by month in 2019? (my biggest spending category)

```{r}
data1<- subset(boadata, Category=='Shopping')
p<- ggplot(data1, aes(x = Month, y=Amount)) + 
  geom_bar(stat = "identity", fill = "Blue")+
  scale_x_discrete(limits=c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")) +
  labs(title = "Shopping Spending per Month", x = "Month", y = "Amount") +
  theme_minimal()
p

```

***
Shopping is my largest purchase category, so I am interested in to see how this category is like on a monthly basis.I noticed that the majority of my Shopping purchases are cosmetics and clothes. As you can tell, most purchase were happening during summer time and winter time when there was seasonal changes and the time of the year people went to outing more often either summer beach or winter sports. It is consistent with my life pattern but the inspiration for me is, for future better financial planning, before the peak shopping season arrives, I can plan ahead to know what are the main purchases I want to buy for this year, instead of randomly shopping in store or online which usually might end up spending more than I actually need.