install.packages ## Introduction
Quantified Self is a movement that has become poular as gathering and analyzing self-tracking data using various tools is easier than ever. By assessing the quantified self data, we are able to track our daily perfomances and behavior and present them in a visualized approach. It will provide perspectives that we haven’t been looked at. Eventually it will help us discover our weakness and strengths so we may be able to perform better in daily decisions and actions.
Personal spending behavior is always an important aspect of our lives. With the growing popularity of using credit card to complete purchases. People can get easier access to detailed transaction details within the monthly statement. With these information, we should be able to do different analysis to observe our spending habits. It will help us manage our wealth, budgeting more accurately and plan for future financial freedom. By utilizing the data gathered from the bank statement, I would like to observe my spending habits in the following areas: 1. What are the top categories where I spend the most using my primary credit card? 2. What is the trend of my monthly-wise in each category using my primary credit card 3. What is the relationship between my spending with my primary credit card VS my income in a monthly basis?
The data is extract from my primary credit card that I use most frequently on a daily basis and the biweekly paycheck deposited in my checking account. The data is from the monthly statement and I saved them in csv format. I categorized my spending in the areas as follow: Monthly Car Payment(Car_Financing),Monthly Rent (Rent), Travel related spending such as flight fee, hotel,rental car and uber (“Travel”), Dining in restuarants (Dining_Out),Gas for the car (Gas),Grocery,a specific column for Cosmetics as it is my interests to try out new products (Cosmetics),since I study a lot in different coffee shops, I set (Coffee) spending as a separate column as well,then some subscriptions such as Amazon, Spotify etc, as (Subscriptions), and shopping for clothes, get hair done or some other leisure spending as “Other”.
set.seed(1) install.packages(“dplyr”) install.packages(“ggplot2”) install.packages(“data.table”) install.packages(“bit64”) install.packages(“corrplot”) install.packages(“ggthemes”) install.packages(“car”) install.packages(“tidyverse”) install.packages(“ggcorrplot”) install.packages(“plotrix”) install.packages(“reshape2”) install.packages(“/Users/JLu/Desktop/512/plotly_4.7.1.tar.gz”, repos = NULL, type=“source”) install.packages(“/Users/JLu/Desktop/512/httpuv_1.4.4.1.tar.gz”, repos = NULL, type=“source”)
#First I imported the data set and did a basic summary for the data set.
spending<-read.csv("/Users/JLu/Desktop/512/Spending Breakdown.csv")
summary(spending)
## Date_Asof Total_Income Total_Expense Credit_Total Car_Financing
## 1/12/18:1 Min. :2932 Min. :2632 $1,619.29 :1 Min. :333
## 2/12/18:1 1st Qu.:3142 1st Qu.:2931 $1,858.42 :1 1st Qu.:333
## 3/12/18:1 Median :3222 Median :3247 $2,097.62 :1 Median :333
## 4/12/18:1 Mean :3192 Mean :3435 $2,370.25 :1 Mean :333
## 5/12/18:1 3rd Qu.:3302 3rd Qu.:3657 $2,735.47 :1 3rd Qu.:333
## 6/12/18:1 Max. :3330 Max. :4866 $3,852.63 :1 Max. :333
## Rent Travel Dining_Out Gas
## Min. :680 Min. :113.7 Min. :226.0 Min. :20.53
## 1st Qu.:680 1st Qu.:322.0 1st Qu.:238.3 1st Qu.:22.23
## Median :680 Median :507.3 Median :258.7 Median :30.13
## Mean :680 Mean :485.8 Mean :334.3 Mean :30.80
## 3rd Qu.:680 3rd Qu.:701.9 3rd Qu.:391.1 3rd Qu.:38.67
## Max. :680 Max. :759.3 Max. :595.4 Max. :42.92
## Grocery Cosmetics Coffee Subscriptions
## Min. : 69.63 Min. : 0.00 Min. : 18.93 Min. : 9.99
## 1st Qu.:169.25 1st Qu.: 0.00 1st Qu.: 43.83 1st Qu.: 9.99
## Median :213.55 Median : 40.95 Median : 63.11 Median : 21.04
## Mean :221.14 Mean : 93.08 Mean : 69.30 Mean : 37.87
## 3rd Qu.:264.14 3rd Qu.:161.37 3rd Qu.: 91.97 3rd Qu.: 32.09
## Max. :394.64 Max. :288.72 Max. :131.66 Max. :133.08
## Other
## Min. : 510.7
## 1st Qu.: 594.3
## Median : 878.4
## Mean :1025.0
## 3rd Qu.:1044.0
## Max. :2283.8
names(spending) <- c("Date_Asof","Total_Income","Total_Expense","Credit_Total","Car_Financing","Rent","Travel","Dining_Out","Gas","Grocery","Cosmetics","Coffee","Subscriptions", "Other")
str(spending)
## 'data.frame': 6 obs. of 14 variables:
## $ Date_Asof : Factor w/ 6 levels "1/12/18","2/12/18",..: 1 2 3 4 5 6
## $ Total_Income : num 3329 3115 3222 3222 3330 ...
## $ Total_Expense: num 2632 3383 2871 3111 3748 ...
## $ Credit_Total : Factor w/ 6 levels "$1,619.29 ","$1,858.42 ",..: 1 4 2 3 5 6
## $ Car_Financing: int 333 333 333 333 333 333
## $ Rent : int 680 680 680 680 680 680
## $ Travel : num 355 660 311 114 716 ...
## $ Dining_Out : num 226 235 248 269 432 ...
## $ Gas : num 23.1 42.9 20.5 39.2 37.1 ...
## $ Grocery : num 272.3 394.6 187.3 239.8 69.6 ...
## $ Cosmetics : num 187.9 81.9 0 0 288.7 ...
## $ Coffee : num 44.3 81.9 43.7 131.7 95.3 ...
## $ Subscriptions: num 32.09 32.09 133.08 9.99 9.99 ...
## $ Other : num 511 842 915 512 1087 ...
You can also embed plots, for example:
## Warning: package 'plotrix' was built under R version 3.4.4
## [1] 1998
## [1] 4080
## [1] 2914.67
## [1] 2005.53
## [1] 184.82
## [1] 1326.86
## [1] 558.48
## [1] 415.8
## [1] 227.23
## [1] 6150.05
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.
## Warning: package 'reshape2' was built under R version 3.4.3
## Date_Asof Total_Income Total_Expense Credit_Total Car_Financing Rent
## 1 1/12/18 3329.24 2632.29 $1,619.29 333 680
## 2 2/12/18 3114.84 3383.25 $2,370.25 333 680
## 3 3/12/18 3222.06 2871.42 $1,858.42 333 680
## 4 4/12/18 3222.06 3110.62 $2,097.62 333 680
## 5 5/12/18 3330.17 3748.47 $2,735.47 333 680
## 6 6/12/18 2931.79 4865.63 $3,852.63 333 680
## Travel Dining_Out Gas Grocery Cosmetics Coffee Subscriptions Other
## 1 355.00 226.00 23.14 272.27 187.86 44.33 32.09 510.69
## 2 659.67 235.11 42.92 394.64 81.90 81.89 32.09 842.03
## 3 311.00 248.01 20.53 187.34 0.00 43.66 133.08 914.80
## 4 113.67 269.34 39.19 239.76 0.00 131.66 9.99 511.69
## 5 716.00 431.67 37.12 69.63 288.72 95.33 9.99 1087.01
## 6 759.33 595.40 21.92 163.22 0.00 18.93 9.99 2283.83
## Date_Asof Total_Income Total_Expense Credit_Total Car_Financing Rent
## 1 1/12/18 3329.24 2632.29 $1,619.29 333 680
## 2 2/12/18 3114.84 3383.25 $2,370.25 333 680
## 3 3/12/18 3222.06 2871.42 $1,858.42 333 680
## 4 4/12/18 3222.06 3110.62 $2,097.62 333 680
## 5 5/12/18 3330.17 3748.47 $2,735.47 333 680
## 6 6/12/18 2931.79 4865.63 $3,852.63 333 680
## Travel Dining_Out Gas Grocery Cosmetics Coffee Subscriptions Other
## 1 355.00 226.00 23.14 272.27 187.86 44.33 32.09 510.69
## 2 659.67 235.11 42.92 394.64 81.90 81.89 32.09 842.03
## 3 311.00 248.01 20.53 187.34 0.00 43.66 133.08 914.80
## 4 113.67 269.34 39.19 239.76 0.00 131.66 9.99 511.69
## 5 716.00 431.67 37.12 69.63 288.72 95.33 9.99 1087.01
## 6 759.33 595.40 21.92 163.22 0.00 18.93 9.99 2283.83