Finance Tracker Dashboard in Data Analysis Using R

Last Updated : 23 Jun, 2025

Managing personal finances is important for maintaining financial health and achieving financial goals. Building a personal finance tracker dashboard in R can provide valuable insights into income, expenses, savings and investment performance. In this article, we'll outline the steps to create a simple yet effective personal finance tracker dashboard using R and popular visualization libraries like ggplot2 and shiny.

1. Data Collection and Preparation

Start by gathering your financial data from sources such as bank statements, credit card statements, investment accounts and budgeting apps. Organize the data into a structured format, such as a CSV file, with columns for date, category, amount and description.

Dataset Link: Personal Finance

2. Data Analysis and Visualization

Use R and ggplot2 to analyze and visualize your financial data. Create visualizations such as:

rmark
Finance Tracker Dashboard in Data Analysis Using R

2.1. Creating dashboard templet

We are using R studio, so the first thing we have to do as follows:

Go to File --> New file --> R markdown --> Templet --> Flex Dashboard --> Click ok

After clicking on that we get this window.

creattemplet
Finance Tracker Dashboard in Data Analysis Using R

Then you get a template look like as follows:

templet
Finance Tracker Dashboard in Data Analysis Using R

Dashboard layout

Now we will create the Dashboard layout and pass the arguments in a chunks.

1. YAML (Header Defines):

This section describes the dashboard's title and layout choices. The dashboard will have social sharing buttons and rows as its main layout style.

R
---
title: "Personal Finance"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
    social: [ "twitter", "facebook", "menu"]
---

2. Setup Chunk

We load all the necessary libraries in this chunk

R
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(highcharter)
library(gt)
library(DT)
library(htmltools)
library(plotly)
library(ggplot2)
library(plyr)
library(rpivotTable)
library(lubridate)
```

3. Loading the Dataset

We will load our dataset using read_csv() function.

R
```{r}
# Import data
library(readxl)
df = read_csv("/content/personal-finance-dataxlsx---Sheet1.csv")
```

The dashboard is divided into rows and columns, each of containing tables or different visuals.

Creating value box and gauge chart

This section computes the mean salary by filtering the data for salary portions. The average monthly salary is shown visually on a gauge chart.

R
### **Salary per Month**
```{r}
df_salary = df %>%
  select(Category,`Debit/Credit`) %>%
  filter(tolower(Category) == "salary")
gauge(round(mean(df_salary$`Debit/Credit`),
            digits = 2),
      min = 0,
      max = 100000,
      gaugeSectors(colors = "yellow"))
```

Output:

gauge
Personal Finance Tracker Dashboard

Similarly we made:

R
### Others Income

```{r}
df_other = df %>%
  select(Category,`Income/Expense`,`Debit/Credit`) %>%
  filter(tolower(Category) == "other") %>%
  filter(tolower(`Income/Expense`) == "income")

valueBox(sum(df_other$`Debit/Credit`),
         icon = "fa-building")

```

### Total Spending

```{r}
df_ = df %>%
  select(Category,`Income/Expense`,`Debit/Credit`) %>%
  filter(tolower(`Income/Expense`) != "income")
valueBox(sum(df_$`Debit/Credit`),
         icon = "fa-building")
```

### Total Savings

```{r}
df_ = df %>%
  select(Category,`Income/Expense`,`Debit/Credit`) %>%
  filter(tolower(`Income/Expense`) != "income")
df_salary = df %>%
  select(Category,`Income/Expense`,`Debit/Credit`) %>%
  filter(tolower(`Income/Expense`) == "income")
valueBox(sum(df_salary$`Debit/Credit`) - sum(df_$`Debit/Credit`),
         icon = "fa-building")
```
### Maximum Expense

```{r}
df_date = df %>%
  select(`Date / Time`, Category, `Income/Expense`, `Debit/Credit`) %>%
  mutate(`Date / Time` = mdy(`Date / Time`)) %>%   
  filter(tolower(`Income/Expense`) != "income")

df_date$Category = tolower(df_date$Category)
valueBox(max(df_date$`Debit/Credit`), icon = "fa-user")
```

### Average Expense

```{r}
df_date = df %>%
  select(`Date / Time`, Category, `Income/Expense`, `Debit/Credit`) %>%
  mutate(`Date / Time` = mdy(`Date / Time`)) %>%   
  filter(tolower(`Income/Expense`) != "income")

df_date$Category = tolower(df_date$Category)
valueBox(round(mean(df_date$`Debit/Credit`), 2), icon = "fa-user")
```

### Minimum Expense

```{r}
df_date = df %>%
  select(`Date / Time`, Category, `Income/Expense`, `Debit/Credit`) %>%
  mutate(`Date / Time` = mdy(`Date / Time`)) %>%  
  filter(tolower(`Income/Expense`) != "income")

df_date$Category = tolower(df_date$Category)
valueBox(min(df_date$`Debit/Credit`), icon = "fa-user")
```

Creating plots using ggplot2 and make them interactive with Plotly

Combining the power of ggplot2 for static visualizations with the interactivity of Plotly creates dynamic and engaging plots that enhance data exploration and presentation.

R
### **Most Frequently Spending On A Category**

```{r}
df_ = df %>%
  select(Category, `Income/Expense`, `Debit/Credit`) %>%
  filter(tolower(`Income/Expense`) != "income")
df_$Category = tolower(df_$Category)
bar = ggplot(data= df_) +
  geom_bar(aes(x = Category, fill = Category)) +
  guides(fill = F)
ggplotly(bar)

```

Output:

newplot
Personal Finance Tracker Dashboard

Similarly we made:

R
### **Monthly Spending On Each Category**

```{r}
df_date = df %>%
  select(`Date / Time`, Category, `Income/Expense`, `Debit/Credit`) %>%
  mutate(`Date / Time` = mdy(`Date / Time`)) %>%   
  filter(tolower(`Income/Expense`) != "income")

df_date$Category = tolower(df_date$Category)

l1 = ggplot(df_date, aes(x = `Date / Time`, y = `Debit/Credit`, color = Category)) +
  geom_line() +
  labs(x = "Date", y = "Debit/Credit", color = "Category")
ggplotly(l1)

```

Create a new page for the pivot table

Applies PivotTable to create a pivot table to summarize the spending of a person by category.

R
Table Spending In Each Category
==========================================================

```{r}
df_11 = df %>%
  select(`Date / Time`, Category, `Income/Expense`, `Debit/Credit`) %>%
  mutate(`Date / Time` = mdy(`Date / Time`)) %>%   
  filter(tolower(`Income/Expense`) != "income")

df_11$Category = tolower(df_11$Category)

rpivotTable(df_11,
            aggregatorName = "sum",
            cols= "`Debit/Credit`",
            rows = "Category" ,
            rendererName = "Table Barchart")

```


Output:

There are lots of options you can use in the pivot table.

charts
Finance Tracker Dashboard in Data Analysis Using R

Creating Data Table

Create a new page and using 'DT::datatable' to display the data in an interactive table in the new page.

R
Data Table
=============================================================

```{r}
datatable(df,
          caption = "Personal Finance Data",
          rownames = T,
          filter = "top",
          options = list(pageLength = 25))
```

Output:

databorad
Finance Tracker Dashboard in Data Analysis Using R

It will show the complete visualization in the R Dashboard.

Complete Code Block

Here is the whole code for the process of creating the Personal Finance Tracker Dashboard.

R
---
title: "Personal Finance"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
    social: [ "twitter", "facebook", "menu"]
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(highcharter)
library(gt)
library(DT)
library(htmltools)
library(plotly)
library(ggplot2)
library(plyr)
library(rpivotTable)
library(lubridate)
```


```{r}
# Import data
library(readxl)
df = read_csv("/content/personal-finance-dataxlsx---Sheet1.csv")
```

Personal Finance
=======================================================================

Column
-----------------------------------------------------------------------

### **Salary per Month**
```{r}
df_salary = df %>%
  select(Category,`Debit/Credit`) %>%
  filter(tolower(Category) == "salary")
gauge(round(mean(df_salary$`Debit/Credit`),
            digits = 2),
      min = 0,
      max = 100000,
      gaugeSectors(colors = "yellow"))
```

### Total Allowences Get

```{r}
df_all = df %>%
  select(Category,`Debit/Credit`) %>%
  filter(tolower(Category) == "allowance")

valueBox(sum(df_all$`Debit.Credit`),
         icon = "fa-building")
```

### Others Income

```{r}
df_other = df %>%
  select(Category,`Income/Expense`,`Debit/Credit`) %>%
  filter(tolower(Category) == "other") %>%
  filter(tolower(`Income/Expense`) == "income")

valueBox(sum(df_other$`Debit/Credit`),
         icon = "fa-building")

```

### Total Spending

```{r}
df_ = df %>%
  select(Category,`Income/Expense`,`Debit/Credit`) %>%
  filter(tolower(`Income/Expense`) != "income")
valueBox(sum(df_$`Debit/Credit`),
         icon = "fa-building")
```

### Total Savings

```{r}
df_ = df %>%
  select(Category,`Income/Expense`,`Debit/Credit`) %>%
  filter(tolower(`Income/Expense`) != "income")
df_salary = df %>%
  select(Category,`Income/Expense`,`Debit/Credit`) %>%
  filter(tolower(`Income/Expense`) == "income")
valueBox(sum(df_salary$`Debit/Credit`) - sum(df_$`Debit/Credit`),
         icon = "fa-building")
```


Row
-----------------------------------------------------------

### **Most Frequently Spending On A Category**

```{r}
df_ = df %>%
  select(Category, `Income/Expense`, `Debit/Credit`) %>%
  filter(tolower(`Income/Expense`) != "income")
df_$Category = tolower(df_$Category)
bar = ggplot(data= df_) +
  geom_bar(aes(x = Category, fill = Category)) +
  guides(fill = F)
ggplotly(bar)

```

### **Monthly Spending On Each Category**

```{r}
df_date = df %>%
  select(`Date / Time`, Category, `Income/Expense`, `Debit/Credit`) %>%
  mutate(`Date / Time` = mdy(`Date / Time`)) %>%   
  filter(tolower(`Income/Expense`) != "income")

df_date$Category = tolower(df_date$Category)

l1 = ggplot(df_date, aes(x = `Date / Time`, y = `Debit/Credit`, color = Category)) +
  geom_line() +
  labs(x = "Date", y = "Debit/Credit", color = "Category")
ggplotly(l1)

```

Row
-----------------------------------------------------------------------

### Maximum Expense

```{r}
df_date = df %>%
  select(`Date / Time`, Category, `Income/Expense`, `Debit/Credit`) %>%
  mutate(`Date / Time` = mdy(`Date / Time`)) %>%   
  filter(tolower(`Income/Expense`) != "income")

df_date$Category = tolower(df_date$Category)
valueBox(max(df_date$`Debit/Credit`), icon = "fa-user")
```

### Average Expense

```{r}
df_date = df %>%
  select(`Date / Time`, Category, `Income/Expense`, `Debit/Credit`) %>%
  mutate(`Date / Time` = mdy(`Date / Time`)) %>%   
  filter(tolower(`Income/Expense`) != "income")

df_date$Category = tolower(df_date$Category)
valueBox(round(mean(df_date$`Debit/Credit`), 2), icon = "fa-user")
```

### Minimum Expense

```{r}
df_date = df %>%
  select(`Date / Time`, Category, `Income/Expense`, `Debit/Credit`) %>%
  mutate(`Date / Time` = mdy(`Date / Time`)) %>%  
  filter(tolower(`Income/Expense`) != "income")

df_date$Category = tolower(df_date$Category)
valueBox(min(df_date$`Debit/Credit`), icon = "fa-user")
```
Table Spending In Each Category
==========================================================

```{r}
df_11 = df %>%
  select(`Date / Time`, Category, `Income/Expense`, `Debit/Credit`) %>%
  mutate(`Date / Time` = mdy(`Date / Time`)) %>%   
  filter(tolower(`Income/Expense`) != "income")

df_11$Category = tolower(df_11$Category)

rpivotTable(df_11,
            aggregatorName = "sum",
            cols= "`Debit/Credit`",
            rows = "Category" ,
            rendererName = "Table Barchart")

```

Data Table
=============================================================

```{r}
datatable(df,
          caption = "Personal Finance Data",
          rownames = T,
          filter = "top",
          options = list(pageLength = 25))
```

Output:

Personal-Finance
Finance Tracker Dashboard in Data Analysis Using R

After knitting the current file we get the below output and you can then publish your dash board on the web.

charts2
Finance Tracker Dashboard in Data Analysis Using R

After knitting the current file we get the below output and you can then publish your dash board on the web.

Dashborad3
Finance Tracker Dashboard in Data Analysis Using R

Overall, this flex dashboard provides a comprehensive overview of personal finance data, allowing users to analyze income, expenses, savings and spending patterns effectively. It offers a combination of visualizations and summary statistics for better understanding and decision-making regarding personal finances.

Comment

Explore