Which are most frequent type of charges on the credit card?

Which is the most frequent charge on Credit Card?

Which is the highest charge on Credit Card?

Comparision of highest charge and most frequent charge(Doller)?

Comparision of highest charge and most frequent charge(Count)?

---
title: "Final Projetc ANLY512"
author: Nikhil Chate
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    storyboard: true
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(lubridate)
library(tidyverse)
library(plotly)

CC<- read.csv("Chase5036_Activity_20180818.CSV")
CC$Trans_Date<- mdy(CC$Trans.Date)
CC$Post_Date<- mdy(CC$Post.Date)

```


###Which are most frequent type of charges on the credit card?
```{r}
ggplot(data=CC, mapping=aes(x=Trans_Date, y=Amount,color=Type))+
  geom_point(size=rel(2))+
  xlab("Transaction Date")+
  ylab("Amount in Dollers")+
  theme(plot.background = element_rect(fill='lightgreen'),panel.background = element_rect(fill = "white",colour = "blue",size = 2, linetype = "solid"),
        panel.grid = element_blank(), plot.title = element_text(size = rel(2)),
        axis.text = element_text(colour = "blue"), axis.title.y = element_text(size = rel(1.5)),axis.title.x = element_text(size = rel(1.5)),
        legend.position = "bottom",legend.key = element_rect(fill = "white", colour = "black"))+
  labs(title="Summary of type of transaction", caption="negative values are sales")



```




###Which is the most frequent charge on Credit Card? 

```{r}
sale<- filter(CC,Type=="Sale")

sale1<- transform(sale, freq.loc = ave(seq(nrow(sale)), Description, FUN=length))


ggplot(filter(sale1,freq.loc >=5),mapping=aes(x=Description,fill=Description))+
  geom_bar(show.legend = FALSE,width = 1)+
  labs(x = NULL, y = NULL)+
  theme(plot.background = element_rect(fill='lightgreen'),panel.background = element_rect(fill = "white",colour = "blue",size = 2, linetype = "solid"),
        panel.grid = element_blank(), plot.title = element_text(size = rel(2)),
        axis.text = element_text(colour = "blue"),aspect.ratio = 1)+
       labs(title="Top 5 Categories of Sale by count")+
       coord_polar()

```


###Which is the highest charge on Credit Card?

```{r}

doller<- sale1 %>% group_by(Description,freq.loc) %>%
summarise(Amount=sum(Amount)) %>%
  arrange((Amount))
doller = doller[1:5,]


p <- doller %>%
  group_by(Description,Amount) %>%
  summarise(Doller=sum((-1)*Amount)) %>%
  plot_ly(labels = ~Description, values = ~Doller) %>%
  add_pie(hole = 0.6) %>%
  layout(title = "Top Charges by doller Amount",  showlegend = F,
         xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
         yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))

p


```




###Comparision of highest charge and most frequent charge(Doller)?

```{r}
doller = doller[1:5,]
Count =filter(sale1,freq.loc >=5)
Count =Count[1:5,]


ggplot(data = doller) + 
  geom_point(mapping = aes(x = Amount, y =freq.loc), color="red", size=4) + 
  xlab("Amount in Dollers")+
  ylab("Charge Frequency")+
  theme(panel.background = element_rect(fill = "lightblue"), axis.text = element_text(colour = "blue"),
        axis.title.y = element_text(size = rel(1.5)),axis.title.x = element_text(size = rel(1.5)))+
  labs(title="Doller vs frequency of Top 5 Doller",caption="negative values are sales")+
  facet_wrap(~Description , nrow = 2)
```

###Comparision of highest charge and most frequent charge(Count)?
```{r}
ggplot(data = Count) + 
  xlab("Amount in Dollers")+
  ylab("Charge Frequency")+
  geom_point(mapping = aes(x = Amount, y =freq.loc), color="red", size=4) + 
  theme(panel.background = element_rect(fill = "lightblue"), axis.text = element_text(colour = "blue"),
        axis.title.y = element_text(size = rel(1.5)),axis.title.x = element_text(size = rel(1.5)))+
  labs(title="Doller vs frequency of Top 5 Count",caption="negative values are sales")+
  facet_wrap(~Description , nrow = 2)


```