## 3210448065@qq.com
## leiou123

## 2849108450@qq.com
## 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)



1 数据


1.1 读取数据


读取样本数据。

## 读取数据
fls <- suppressWarnings(list.files('data/会员报表'))
smp <- fls %>% llply(., function(x) {
    dtt <- x %>% str_replace_all('.xls', '') %>% ymd
    smpp <- read_excel(paste0('data/会员报表/', x)) %>% 
      .[-nrow(.),]
    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'))))

上图显示从2020-05-27到2020-07-24的会员报表数据。



1.2 分析数据


lv_sum <- smp %>% 
  group_by(日期, 等级) %>% 
  group_split() %>% 
  llply(., function(x) {
    x1 <- x[,c(1, 3)]
    x2 <- x[,-c(1:4)]
    data.frame(x1[1,], '投注人数' = nrow(x), t(colSums(x2))) %>% 
      mutate(`盈率` = 盈利 / 有效总投注)
    }) %>% bind_rows %>% as_tibble

lv_mean <- smp %>% 
  group_by(日期, 等级) %>% 
  group_split() %>% 
  llply(., function(x) {
    x1 <- x[,c(1, 3)]
    x2 <- x[,-c(1:4)]
    data.frame(x1[1,], '投注人数' = nrow(x), t(colMeans(x2))) %>% 
      mutate(`盈率` = 盈利 / 有效总投注)
    }) %>% bind_rows %>% as_tibble

下个章节将以:

  • 等级为标准,然后以总额来分析什么等级的会员为公司带来的商业效应。
  • 等级为标准,然后以平均值来分析什么等级的会员为公司带来的商业效应。



2 绘图


2.1 等级(总额)


2.1.1 投注人数


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的投注人数,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.2 会员余额


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的会员余额,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.3 充值金额


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的充值金额,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.4 提现金额


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的提现金额,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.5 有效总投注


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的有效总投注,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.6 中奖总金额


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的中奖总金额,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.7 下级返点


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的下级返点,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.8 自身返点


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的自身返点,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.9 代理佣金


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的代理佣金,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.10 总活动礼金


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的总活动礼金,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.11 存款优惠


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的存款优惠,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.12 盈利


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的盈利,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.1.13 盈率


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 = '截图')
lv_sum %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的盈率,默认设置显示所有等级,可以点击等级筛选焦点等级。



2.2 等级(平均值)


2.2.1 投注人数


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的投注人数,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.2 会员余额


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的会员余额,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.3 充值金额


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的充值金额,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.4 提现金额


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的提现金额,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.5 有效总投注


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的有效总投注,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.6 中奖总金额


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的中奖总金额,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.7 下级返点


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的下级返点,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.8 自身返点


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的自身返点,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.9 代理佣金


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的代理佣金,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.10 总活动礼金


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的总活动礼金,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.11 存款优惠


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的存款优惠,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.12 盈利


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的盈利,默认设置显示所有等级,可以点击等级筛选焦点等级。


2.2.13 盈率


lv_mean %>% 
    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 = '截图')

上图显示从2020-05-27到2020-07-24的盈率,默认设置显示所有等级,可以点击等级筛选焦点等级。



3 结论


3.1 总结


以上是将数据绘图,还需要通过统计模型预测,不过基于数据观测值太少1,所以暂时没有预测。


3.2 附录


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'))
Additional session information:
Category session_info Category Sys.info
version R version 4.0.2 (2020-06-22) sysname Linux
os Ubuntu 16.04.6 LTS release 5.3.0-1017-aws
system x86_64, linux-gnu version #18~18.04.1-Ubuntu SMP Wed Apr 8 15:12:16 UTC 2020
ui X11 nodename application-2613621-deployment-6783693-jlfct
language (EN) machine x86_64
collate C.UTF-8 login unknown
ctype C.UTF-8 user rstudio-user
tz Etc/UTC effective_user rstudio-user
date 2020-07-26 Current time 2020-07-26 23:21:26 JST
rm(sys1, sys2)

  1. binary.com Interview Question I (Extention)尝试分别使用3个月6个月12个月18个月24个月的数据,结果12个月的数据最为精准。↩︎