-
Notifications
You must be signed in to change notification settings - Fork 1
/
会员报表.Rmd
367 lines (312 loc) · 11.1 KB
/
会员报表.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
---
title: "阿里彩票"
subtitle: "会员报表报告"
author: "雷欧 <img src='figure/cd23-isqivxh1309422.jpg' width='24'>"
date: "`r lubridate::today()`"
output:
html_document:
number_sections: yes
toc: yes
toc_depth: 4
toc_float:
collapsed: yes
smooth_scroll: yes
code_folding: hide
---
```{r warning = FALSE, message=FALSE}
## leiou123
## leiou123
## https://rstudio.cloud/project/1198888
pkg <- c('plyr', 'tidyverse', 'magrittr', 'readr', 'readxl', 'tidyr',
'knitr', 'kableExtra', 'forecast', 'formattable', 'DT',
'lubridate', 'highcharter', 'htmltools', 'echarts4r')
plyr::l_ply(pkg, require, quietly = TRUE, character.only = TRUE, .print = FALSE)
```
# 数据
读取样本数据。
```{r warning = FALSE}
## 读取数据
fls <- suppressWarnings(list.files('data/会员报表'))
smp <- fls %>% llply(., function(x) {
dtt <- x %>% str_replace_all('.xls', '') %>% ymd
smpp <- read_excel(paste0('data/会员报表/', x))
data.frame('日期' = dtt, smpp)
}) %>% bind_rows %>%
as_tibble %>%
mutate('用户账号' = factor(用户账号),
'等级' = factor(等级),
'上级代理' = factor(上级代理),
'盈率' = as.numeric(percent(盈率))) %>%
mutate_if(is.character, as.numeric)
rm(fls)
smp %>% datatable(
caption = "会员报表数据",
escape = FALSE, filter = 'top', rownames = FALSE,
extensions = list('ColReorder' = NULL, 'RowReorder' = NULL,
'Buttons' = NULL, 'Responsive' = NULL),
options = list(dom = 'BRrltpi', autoWidth = TRUE, scrollX = TRUE,
lengthMenu = list(c(10, 50, 100, 500, -1),
c('10', '50', '100', '500', 'All')),
ColReorder = TRUE, rowReorder = TRUE,
buttons = list('copy', 'print',
list(extend = 'collection',
buttons = c('csv', 'excel', 'pdf'),
text = 'Download'), I('colvis'))))
```
上图显示从`r smp$'日期' %>% range %>% .[1]`到`r smp$'日期' %>% range %>% .[2]`的报表数据。
<br>
<br>
# 绘图
<br>
## 投注人数
```{r warning = FALSE, eval = FALSE, results = 'asis'}
pl1 <- smp %>%
highchart() %>%
hc_chart('line', hcaes(x = 日期, y = 投注人数, group = 彩种名称)) %>%
hc_title(text = '用户账号') %>%
hc_subtitle(text = '投注人数')
tagList(pl1)
```
```{r}
smp %>%
group_by(彩种名称) %>%
e_charts(x = 日期) %>%
e_line(投注人数, smooth = TRUE) %>%
e_datazoom(
type = 'slider',
toolbox = FALSE,
bottom = -5) %>%
e_tooltip() %>%
e_title(text = '彩种', subtext = '投注人数', left = 'center') %>%
e_axis_labels(x = '日期', y = '投注人数') %>%
e_x_axis(日期, axisPointer = list(show = TRUE)) %>%
e_legend(
orient = 'vertical',
type = c('scroll'),
#selectedMode = 'multiple', #https://echarts.apache.org/en/option.html#legend
#selected = list('彩种'),
left = 0, top = 80) %>%
e_grid(left = 150, top = 90) %>%
#e_theme('shine') %>%
e_toolbox_feature('saveAsImage', title = '截图')
```
上图显示从`r smp$'日期' %>% range %>% .[1]`到`r smp$'日期' %>% range %>% .[2]`的**投注人数**,默认设置显示所有彩种,可以点击彩种筛选焦点彩种。
<br>
## 投注金额
```{r warning = FALSE, eval = FALSE, results = 'asis'}
smp %>%
hchart('line', hcaes(x = 日期, y = 投注金额, group = 彩种名称)) %>%
hc_title(text = '彩种') %>%
hc_subtitle(text = '投注金额')
```
```{r}
smp %>%
group_by(彩种名称) %>%
e_charts(x = 日期) %>%
e_line(投注金额, smooth = TRUE) %>%
e_datazoom(
type = 'slider',
toolbox = FALSE,
bottom = -5) %>%
e_tooltip() %>%
e_title(text = '彩种', subtext = '投注金额', left = 'center') %>%
e_axis_labels(x = '日期', y = '投注金额') %>%
e_x_axis(日期, axisPointer = list(show = TRUE)) %>%
e_legend(
orient = 'vertical',
type = c('scroll'),
left = 0, top = 80) %>%
e_grid(left = 150, top = 90) %>%
#e_theme('shine') %>%
e_toolbox_feature('saveAsImage', title = '截图')
```
上图显示从`r smp$'日期' %>% range %>% .[1]`到`r smp$'日期' %>% range %>% .[2]`的**投注金额**,默认设置显示所有彩种,可以点击彩种筛选焦点彩种。
<br>
## 中奖金额
```{r warning = FALSE, eval = FALSE, results = 'asis'}
smp %>%
hchart('line', hcaes(x = 日期, y = 投注金额, group = 彩种名称)) %>%
hc_title(text = '彩种') %>%
hc_subtitle(text = '中奖金额')
```
```{r}
smp %>%
group_by(彩种名称) %>%
e_charts(x = 日期) %>%
e_line(中奖金额, smooth = TRUE) %>%
e_datazoom(
type = 'slider',
toolbox = FALSE,
bottom = -5) %>%
e_tooltip() %>%
e_title(text = '彩种', subtext = '中奖金额', left = 'center') %>%
e_axis_labels(x = '日期', y = '中奖金额') %>%
e_x_axis(日期, axisPointer = list(show = TRUE)) %>%
e_legend(
orient = 'vertical',
type = c('scroll'),
left = 0, top = 80) %>%
e_grid(left = 150, top = 90) %>%
#e_theme('shine') %>%
e_toolbox_feature('saveAsImage', title = '截图')
```
上图显示从`r smp$'日期' %>% range %>% .[1]`到`r smp$'日期' %>% range %>% .[2]`的**中奖金额**,默认设置显示所有彩种,可以点击彩种筛选焦点彩种。
<br>
## 撤单金额
```{r warning = FALSE, eval = FALSE, results = 'asis'}
smp %>%
hchart('line', hcaes(x = 日期, y = 投注金额, group = 彩种名称)) %>%
hc_title(text = '彩种') %>%
hc_subtitle(text = '撤单金额')
```
```{r}
smp %>%
group_by(彩种名称) %>%
e_charts(x = 日期) %>%
e_line(撤单金额, smooth = TRUE) %>%
e_datazoom(
type = 'slider',
toolbox = FALSE,
bottom = -5) %>%
e_tooltip() %>%
e_title(text = '彩种', subtext = '撤单金额', left = 'center') %>%
e_axis_labels(x = '日期', y = '撤单金额') %>%
e_x_axis(日期, axisPointer = list(show = TRUE)) %>%
e_legend(
orient = 'vertical',
type = c('scroll'),
left = 0, top = 80) %>%
e_grid(left = 150, top = 90) %>%
#e_theme('shine') %>%
e_toolbox_feature('saveAsImage', title = '截图')
```
上图显示从`r smp$'日期' %>% range %>% .[1]`到`r smp$'日期' %>% range %>% .[2]`的**撤单金额**,默认设置显示所有彩种,可以点击彩种筛选焦点彩种。
<br>
## 返点金额
```{r warning = FALSE, eval = FALSE, results = 'asis'}
smp %>%
hchart('line', hcaes(x = 日期, y = 投注金额, group = 彩种名称)) %>%
hc_title(text = '彩种') %>%
hc_subtitle(text = '返点金额')
```
```{r}
smp %>%
group_by(彩种名称) %>%
e_charts(x = 日期) %>%
e_line(返点金额, smooth = TRUE) %>%
e_datazoom(
type = 'slider',
toolbox = FALSE,
bottom = -5) %>%
e_tooltip() %>%
e_title(text = '彩种', subtext = '返点金额', left = 'center') %>%
e_axis_labels(x = '日期', y = '返点金额') %>%
e_x_axis(日期, axisPointer = list(show = TRUE)) %>%
e_legend(
orient = 'vertical',
type = c('scroll'),
left = 0, top = 80) %>%
e_grid(left = 150, top = 90) %>%
#e_theme('shine') %>%
e_toolbox_feature('saveAsImage', title = '截图')
```
上图显示从`r smp$'日期' %>% range %>% .[1]`到`r smp$'日期' %>% range %>% .[2]`的**返点金额**,默认设置显示所有彩种,可以点击彩种筛选焦点彩种。
<br>
## 盈利
```{r warning = FALSE, eval = FALSE, results = 'asis'}
smp %>%
hchart('line', hcaes(x = 日期, y = 投注金额, group = 彩种名称)) %>%
hc_title(text = '彩种') %>%
hc_subtitle(text = '盈利')
```
```{r}
smp %>%
group_by(彩种名称) %>%
e_charts(x = 日期) %>%
e_line(盈利, smooth = TRUE) %>%
e_datazoom(
type = 'slider',
toolbox = FALSE,
bottom = -5) %>%
e_tooltip() %>%
e_title(text = '彩种', subtext = '盈利', left = 'center') %>%
e_axis_labels(x = '日期', y = '盈利') %>%
e_x_axis(日期, axisPointer = list(show = TRUE)) %>%
e_legend(
orient = 'vertical',
type = c('scroll'),
left = 0, top = 80) %>%
e_grid(left = 150, top = 90) %>%
#e_theme('shine') %>%
e_toolbox_feature('saveAsImage', title = '截图')
```
上图显示从`r smp$'日期' %>% range %>% .[1]`到`r smp$'日期' %>% range %>% .[2]`的**盈利**,默认设置显示所有彩种,可以点击彩种筛选焦点彩种。
<br>
## 盈率
```{r warning = FALSE, eval = FALSE, results = 'asis'}
smp %>%
hchart('line', hcaes(x = 日期, y = 投注金额, group = 彩种名称)) %>%
hc_title(text = '彩种') %>%
hc_subtitle(text = '盈率')
```
```{r}
smp %>%
group_by(彩种名称) %>%
e_charts(x = 日期) %>%
e_line(盈率, smooth = TRUE) %>%
e_datazoom(
type = 'slider',
toolbox = FALSE,
bottom = -5) %>%
e_tooltip() %>%
e_title(text = '彩种', subtext = '盈率', left = 'center') %>%
e_axis_labels(x = '日期', y = '盈率') %>%
e_x_axis(日期, axisPointer = list(show = TRUE)) %>%
e_legend(
orient = 'vertical',
type = c('scroll'),
left = 0, top = 80) %>%
e_grid(left = 150, top = 90) %>%
#e_theme('shine') %>%
e_toolbox_feature('saveAsImage', title = '截图')
```
上图显示从`r smp$'日期' %>% range %>% .[1]`到`r smp$'日期' %>% range %>% .[2]`的**盈率**,默认设置显示所有彩种,可以点击彩种筛选焦点彩种。
<br>
<br>
# 结论
<br>
## 总结
以上是将数据绘图,还需要通过统计模型预测,不过基于数据观测值太少^[[binary.com Interview Question I (Extention)](https://rpubs.com/englianhu/binary-Q1E)尝试分别使用`3个月`、`6个月`、`12个月`、`18个月`和`24个月`的数据,结果`12个月`的数据最为精准。],所以暂时没有预测。
<br>
## 附录
```{r warning = FALSE, results = 'asis'}
suppressMessages(require('dplyr', quietly = TRUE))
suppressMessages(require('formattable', quietly = TRUE))
suppressMessages(require('knitr', quietly = TRUE))
suppressMessages(require('kableExtra', quietly = TRUE))
sys1 <- devtools::session_info()$platform %>%
unlist %>% data.frame(Category = names(.), session_info = .)
rownames(sys1) <- NULL
#sys1 %<>% rbind(., data.frame(
# Category = 'Current time',
# session_info = paste(as.character(lubridate::now('Asia/Tokyo')), 'JST'))) %>%
# dplyr::filter(Category != 'os')
sys2 <- data.frame(Sys.info()) %>% mutate(Category = rownames(.)) %>% .[2:1]
names(sys2)[2] <- c('Sys.info')
rownames(sys2) <- NULL
if (nrow(sys1) == 7 & nrow(sys2) == 8) {
sys1 %<>% rbind(., data.frame(
Category = 'Current time',
session_info = paste(as.character(lubridate::now('Asia/Tokyo')), 'JST')))
} else {
sys2 %<>% rbind(., data.frame(
Category = 'Current time',
Sys.info = paste(as.character(lubridate::now('Asia/Tokyo')), 'JST')))
}
cbind(sys1, sys2) %>%
kable(caption = 'Additional session information:') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive'))
rm(sys1, sys2)
```