library(tidyverse)
library(knitr)
library(kableExtra)
ggplot(amazondata, aes(amazondata$`Item Total`)) +
geom_histogram(bins = 10, aes(fill = amazondata$Category)) +
xlab("Item total price") +
labs(fill = "Category") +
ggtitle("Amazon 2017 Purchase history count vs. total price")

ggplot(amazondata, aes(amazondata$Category ,amazondata$`Item Total`)) +
geom_boxplot(aes(fill = amazondata$Category)) +
coord_flip() +
theme_dark() +
ylab("Item total (Subtotal + tax)") +
xlab("Category") +
theme(legend.position = "none")

ggplot(amazondata, aes(amazondata$`Item Total`, amazondata$Category)) +
geom_point(aes(color = amazondata$Category)) +
theme(legend.position = "none") +
xlab("Item total (Subtotal + tax)") +
ylab("Category")

amazondata2 <- amazondata %>% select(`Item Total`, Category)
data1 <- group_by(amazondata2, Category) %>% summarise_all(funs(count=n(), mean, median, max, min, sum))
kable(data1, "html", escape = F) %>%
kable_styling("striped", full_width = T) %>%
column_spec(1, bold = T)
Category
|
count
|
mean
|
median
|
max
|
min
|
sum
|
Accessory
|
1
|
188.00000
|
188.000
|
188.00
|
188.00
|
188.00
|
Apparel
|
8
|
20.42875
|
20.025
|
34.95
|
6.62
|
163.43
|
Automotive
|
13
|
28.65000
|
17.350
|
164.25
|
7.08
|
372.45
|
DVD
|
2
|
9.58500
|
9.585
|
10.67
|
8.50
|
19.17
|
Electronics
|
12
|
60.49500
|
22.990
|
250.40
|
5.99
|
725.94
|
Grocery
|
272
|
4.97625
|
3.990
|
23.96
|
0.00
|
1353.54
|
Hardcover
|
1
|
30.53000
|
30.530
|
30.53
|
30.53
|
30.53
|
Health and Beauty
|
31
|
24.10903
|
24.240
|
57.99
|
6.75
|
747.38
|
Kitchen
|
30
|
24.48333
|
15.490
|
109.48
|
0.00
|
734.50
|
Lawn & Patio
|
8
|
119.27250
|
125.350
|
259.12
|
19.42
|
954.18
|
Misc.
|
43
|
27.09628
|
14.990
|
239.95
|
3.98
|
1165.14
|
Paperback
|
6
|
14.02167
|
10.230
|
30.43
|
6.29
|
84.13
|
Personal Computers
|
4
|
71.70000
|
53.255
|
163.30
|
16.99
|
286.80
|
Shoes
|
2
|
66.95000
|
66.950
|
110.00
|
23.90
|
133.90
|
Sports
|
3
|
21.74000
|
20.280
|
29.99
|
14.95
|
65.22
|
Tools & Home Improvement
|
11
|
46.46909
|
30.470
|
192.77
|
4.99
|
511.16
|
Toy
|
5
|
14.13400
|
13.600
|
25.95
|
7.10
|
70.67
|
Video Game
|
9
|
32.53000
|
17.130
|
64.22
|
10.99
|
292.77
|
Watch
|
1
|
151.34000
|
151.340
|
151.34
|
151.34
|
151.34
|
Wireless Phone Accessory
|
4
|
14.49500
|
14.200
|
19.59
|
9.99
|
57.98
|
NA
|
19
|
29.28947
|
20.950
|
99.99
|
8.78
|
556.50
|
## The total subtotal: 8307.49
## The total of purchases for 2017: 8664.73