Skip to content

Commit fe5fd68

Browse files
authored
Remove deps #20 (#23)
- remove berryFunctions, glue, stringr from IMPORT dependencies - edit lintr GHA workflow - increment package version - edit NEWS.md with changes in branch references #20
1 parent 627acf1 commit fe5fd68

File tree

7 files changed

+50
-42
lines changed

7 files changed

+50
-42
lines changed

.github/workflows/lint.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
2-
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
31
on:
42
pull_request:
5-
branches: [main, master]
3+
branches:
4+
- main
5+
- master
66

77
name: lint-changed-files
88

99
jobs:
10-
lint:
11-
runs-on: ubuntu-latest
10+
lint-changed-files:
11+
runs-on: ubuntu-20.04
1212
env:
1313
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1414
steps:
1515
- uses: actions/checkout@v2
1616

17-
- uses: r-lib/actions/setup-r@v1
18-
with:
19-
use-public-rspm: true
20-
17+
- uses: r-lib/actions/setup-r@v2
18+
2119
- uses: r-lib/actions/setup-r-dependencies@v1
2220
with:
2321
extra-packages: lintr
24-
22+
2523
- uses: r-lib/actions/setup-r-dependencies@v2
2624
with:
2725
extra-packages: |
@@ -37,3 +35,5 @@ jobs:
3735
exclusions_list <- as.list(setdiff(all_files, changed_files))
3836
lintr::lint_package(exclusions = exclusions_list)
3937
shell: Rscript {0}
38+
39+

DESCRIPTION

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ggshakeR
22
Title: Analytics and Visualization Package for Soccer Data
3-
Version: 0.1.1
3+
Version: 0.1.2
44
Authors@R: c(
55
person(given = "Abhishek Amol",
66
family = "Mishra",
@@ -20,24 +20,19 @@ Roxygen: list(markdown = TRUE)
2020
RoxygenNote: 7.1.2
2121
Imports:
2222
tidyr,
23-
devtools,
2423
magrittr,
2524
dplyr,
2625
ggplot2,
2726
ggsoccer,
2827
ggrepel,
2928
viridis,
30-
roxygen2,
3129
ggtext,
3230
Rcpp,
3331
RcppRoll,
3432
TTR,
3533
stringi,
36-
stringr,
3734
forcats,
38-
wesanderson,
39-
glue,
40-
berryFunctions
35+
wesanderson
4136
Suggests:
4237
rmarkdown,
4338
knitr,

NAMESPACE

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ import(ggplot2)
1919
import(ggrepel)
2020
import(ggsoccer)
2121
import(ggtext)
22-
import(stringi)
23-
import(stringr)
2422
import(viridis)
2523
import(wesanderson)
26-
importFrom(berryFunctions,insertRows)
27-
importFrom(glue,glue)
2824
importFrom(magrittr,"%>%")
25+
importFrom(stringi,stri_trans_general)
26+
importFrom(stringi,stri_wrap)

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# ggshakeR 0.1.2
2+
3+
* Remove extraneous dependencies from package imports
4+
* See [issue #20](https://github.com/abhiamishra/ggshakeR/issues/20)
5+
16
# ggshakeR 0.1.1
27

38
* Implement Github Actions CI tools:

R/plot_pizza.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
#' @import ggplot2
2828
#' @import forcats
2929
#' @import ggtext
30-
#' @import stringr
31-
#' @import stringi
30+
#' @importFrom stringi stri_wrap stri_trans_general
3231
#'
3332
#' @export
3433
#'
@@ -364,7 +363,7 @@ Data from StatsBomb via FBref. Inspired by @NathanAClark. Created using ggshakeR
364363
plot.caption = element_text(hjust = 0.5, size = 15, colour = colorText),
365364
panel.grid.major = element_blank(),
366365
panel.grid.minor = element_blank()) +
367-
scale_x_discrete(labels = function(x) str_wrap(x, width = 10))
366+
scale_x_discrete(labels = function(x) stri_wrap(x, width = 10))
368367

369368
} else if (type == "comparison") { ## COMPARISON PLOT ----
370369

@@ -539,6 +538,6 @@ Data from StatsBomb via FBref. Inspired by @FootballSlices. Created using ggshak
539538
plot.caption = element_text(hjust = 0.5, size = 15, colour = colorText),
540539
panel.grid.major = element_blank(),
541540
panel.grid.minor = element_blank()) +
542-
scale_x_discrete(labels = function(x) str_wrap(x, width = 10))
541+
scale_x_discrete(labels = function(x) stri_wrap(x, width = 10))
543542
}
544543
}

R/plot_timeline.r

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
#' @import dplyr
1515
#' @import ggtext
1616
#' @import ggplot2
17-
#' @importFrom berryFunctions insertRows
1817
#' @import ggrepel
19-
#' @importFrom glue glue
2018
#'
2119
#' @export
2220
#'
@@ -75,35 +73,44 @@ plot_timeline <- function(data, match_year, team_home, team_away, home_color, aw
7573
}
7674

7775
data <- data %>%
78-
filter(season == match_year)
76+
dplyr::filter(season == match_year)
7977

8078
if (!"home_away" %in% colnames(data)) {
8179
data <- data %>%
8280
mutate(home_away = h_a)
8381
}
8482

8583
data <- data %>%
86-
filter(home_team == team_home,
84+
dplyr::filter(home_team == team_home,
8785
away_team == team_away)
8886
data1 <- data %>%
89-
filter(home_away == "h") %>%
87+
dplyr::filter(home_away == "h") %>%
9088
mutate(xGsum = cumsum(xG))
9189
data2 <- data %>%
92-
filter(home_away == "a") %>%
90+
dplyr::filter(home_away == "a") %>%
9391
mutate(xGsum = cumsum(xG))
9492

95-
data1 <- insertRows(data1, 1, new = 0)
96-
data2 <- insertRows(data2, 1, new = 0)
93+
# data1 <- insertRows(data1, 1, new = 0)
94+
# data2 <- insertRows(data2, 1, new = 0)
95+
data1 <- dplyr::add_row(.data = data1, .before = 1,
96+
id = "0", minute = 0, result = "0", X = 0, Y = 0, xG = 0, player = "0", home_away = "0", player_id = "0",
97+
situation = "0", season = "0", shotType = "0", match_id = "0", home_team = "0", away_team = "0",
98+
home_goals = 0, away_goals = 0, date = "0", player_assisted = "0", lastAction = "0", xGsum = 0)
99+
100+
data2 <- dplyr::add_row(.data = data2, .before = 1,
101+
id = "0", minute = 0, result = "0", X = 0, Y = 0, xG = 0, player = "0", home_away = "0", player_id = "0",
102+
situation = "0", season = "0", shotType = "0", match_id = "0", home_team = "0", away_team = "0",
103+
home_goals = 0, away_goals = 0, date = "0", player_assisted = "0", lastAction = "0", xGsum = 0)
97104

98105
dat1 <- data1 %>%
99-
filter(result == "Goal")
106+
dplyr::filter(result == "Goal")
100107
d1 <- data1 %>%
101-
filter(result == "OwnGoal")
108+
dplyr::filter(result == "OwnGoal")
102109
dat1 <- rbind(dat1, d1)
103110
dat2 <- data2 %>%
104-
filter(result == "Goal")
111+
dplyr::filter(result == "Goal")
105112
d2 <- data2 %>%
106-
filter(result == "OwnGoal")
113+
dplyr::filter(result == "OwnGoal")
107114
dat2 <- rbind(dat2, d2)
108115

109116
team1 <- data$home_team
@@ -127,15 +134,18 @@ plot_timeline <- function(data, match_year, team_home, team_away, home_color, aw
127134
gls2 <- "Goals"
128135
}
129136

130-
plot_title <- glue("<b style='color:{home_color}'> {team1} : {g1} {gls1} ({xG1} xG) </b> vs. <b style='color:{away_color}'> {team2} : {g2} {gls2} ({xG2} xG)</b>")
137+
# plot_title <- glue("<b style='color:{home_color}'> {team1} : {g1} {gls1} ({xG1} xG) </b> vs. <b style='color:{away_color}'> {team2} : {g2} {gls2} ({xG2} xG)</b>")
138+
plot_title <- sprintf("<b style='color:%s'> %s : %s %s (%s xG) </b> vs. <b style='color:%s'> %s : %s %s (%s xG)</b>",
139+
home_color, team1, g1, gls1, xG1,
140+
away_color, team2, g2, gls2, xG2)
131141

132142
min1 <- dat1$minute
133143
min2 <- dat2$minute
134144
p1 <- dat1$player
135145
p2 <- dat2$player
136146

137-
player_lab1 <- glue("{p1} : {min1}")
138-
player_lab2 <- glue("{p2} : {min2}")
147+
player_lab1 <- paste0(p1, " : ", min1)
148+
player_lab2 <- paste0(p2, " : ", min2)
139149

140150
plot_timeline <- ggplot() +
141151
geom_step(data = data1, aes(x = minute, y = xGsum), colour = home_color, size = 3) +

R/plot_trendline.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#' @param theme to select the theme from 4 options -> dark, almond, rose, white.
2020
#'
2121
#' @import dplyr
22-
#' @importFrom glue glue
2322
#' @import ggplot2
2423
#' @import ggtext
2524
#' @import Rcpp
@@ -123,7 +122,9 @@ plot_trendline <- function(data, team, colour_xg, colour_xga, roll_avg, theme =
123122
}
124123

125124
team <- paste(team, "xG Trendline")
126-
subtitle <- glue("{roll_avg} Game Rolling Average [<b style='color:{colour_xg}'> xG </b> vs <b style='color:{colour_xga}'> xGA </b>]")
125+
# subtitle <- glue("{roll_avg} Game Rolling Average [<b style='color:{colour_xg}'> xG </b> vs <b style='color:{colour_xga}'> xGA </b>]")
126+
subtitle <- sprintf("%s Game Rolling Average [<b style='color:%s'> xG </b> vs <b style='color:%s'> xGA </b>]",
127+
roll_avg, colour_xg, colour_xga)
127128

128129
ggplot(data, aes(x = Date)) +
129130
geom_line(aes(y = xGSM), colour = colour_xg, size = 3) +

0 commit comments

Comments
 (0)