-
Notifications
You must be signed in to change notification settings - Fork 0
/
career.Rmd
44 lines (39 loc) · 1015 Bytes
/
career.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
---
title: "Career"
---
```{r setup, include=F}
library(tidyverse)
library(openxlsx)
source("stats.R")
knitr::opts_chunk$set(echo = F)
```
```{r read}
conn <- DBI::dbConnect(RSQLite::SQLite(), "stats.sdb")
df.point <- DBI::dbReadTable(conn, "point")
df.lstat <- DBI::dbReadTable(conn, "lstat")
df.penalty <- DBI::dbReadTable(conn, "penalty")
df.player <- DBI::dbReadTable(conn, "player")
DBI::dbDisconnect(conn)
```
```{r career}
df.type1 <- (
group_by(df.lstat, player) %>%
summarise(
EVG = sum(G), EVA = sum(A),
PPG = sum(PPG), PPA = sum(PPA),
SHG = sum(SHG), SHA = sum(SHA),
GWG = sum(GWG),
PIM = sum(PIM)
) %>%
mutate(P = EVG + EVA, G = EVG, A = EVA)
)
df.type2 <- overall.2(df.point, df.penalty)
rename(df.player, player = id) %>%
bind_rows(df.type1, df.type2) %>%
select(player, P, G, A, PIM) %>%
replace(is.na(.), 0) %>%
group_by(player) %>%
summarise(across(matches("[A-Z]+", ignore.case = F), sum)) %>%
arrange(desc(P)) %>%
datatableize()
```