diff --git a/docs/articles/Guide_to_EPV.html b/docs/articles/Guide_to_EPV.html
index 7d4f631..dc377db 100644
--- a/docs/articles/Guide_to_EPV.html
+++ b/docs/articles/Guide_to_EPV.html
@@ -79,7 +79,7 @@
Abhishek A.
Mishra
- 2022-06-25
+ 2022-06-26
Source: vignettes/Guide_to_EPV.Rmd
Guide_to_EPV.Rmd
diff --git a/docs/articles/Guide_to_Exp_Threat.html b/docs/articles/Guide_to_Exp_Threat.html
index 7aa389f..f9afc4e 100644
--- a/docs/articles/Guide_to_Exp_Threat.html
+++ b/docs/articles/Guide_to_Exp_Threat.html
@@ -79,7 +79,7 @@
Abhishek A.
Mishra
- 2022-06-25
+ 2022-06-26
Source: vignettes/Guide_to_Exp_Threat.Rmd
Guide_to_Exp_Threat.Rmd
diff --git a/docs/articles/Guide_to_Pitch_Plots.html b/docs/articles/Guide_to_Pitch_Plots.html
index 0c313e9..1b2a0da 100644
--- a/docs/articles/Guide_to_Pitch_Plots.html
+++ b/docs/articles/Guide_to_Pitch_Plots.html
@@ -79,7 +79,7 @@
Abhishek A.
Mishra
- 2022-06-25
+ 2022-06-26
Source: vignettes/Guide_to_Pitch_Plots.Rmd
Guide_to_Pitch_Plots.Rmd
diff --git a/docs/articles/Guide_to_PizzaPlots.html b/docs/articles/Guide_to_PizzaPlots.html
index 3849826..b390898 100644
--- a/docs/articles/Guide_to_PizzaPlots.html
+++ b/docs/articles/Guide_to_PizzaPlots.html
@@ -79,7 +79,7 @@
Harsh
Krishna
- 2022-06-25
+ 2022-06-26
Source: vignettes/Guide_to_PizzaPlots.Rmd
Guide_to_PizzaPlots.Rmd
diff --git a/docs/articles/Guide_to_Version_0-2-0.html b/docs/articles/Guide_to_Version_0-2-0.html
index 6a9d5e9..f486e82 100644
--- a/docs/articles/Guide_to_Version_0-2-0.html
+++ b/docs/articles/Guide_to_Version_0-2-0.html
@@ -79,7 +79,7 @@
Ryo
Nakagawara
- 2022-06-25
+ 2022-06-26
Source: vignettes/Guide_to_Version_0-2-0.Rmd
Guide_to_Version_0-2-0.Rmd
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index a7e96d8..46bcc57 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -7,7 +7,7 @@ articles:
Guide_to_Pitch_Plots: Guide_to_Pitch_Plots.html
Guide_to_PizzaPlots: Guide_to_PizzaPlots.html
Guide_to_Version_0-2-0: Guide_to_Version_0-2-0.html
-last_built: 2022-06-25T03:08Z
+last_built: 2022-06-26T10:57Z
urls:
reference: https://abhiamishra.github.io/ggshakeR/reference
article: https://abhiamishra.github.io/ggshakeR/articles
diff --git a/tests/testthat/test_functions.R b/tests/testthat/test_functions.R
index 2c4d257..c347e38 100644
--- a/tests/testthat/test_functions.R
+++ b/tests/testthat/test_functions.R
@@ -137,6 +137,10 @@ test_that("Testing plotting passflow maps: ", {
############# |- PLOT_PASS ################
+#StatsBomb dataset
+sbevents <- system.file("testdata", "sbevents.RDS", package = "ggshakeR")
+sb_df <- readRDS(sbevents)
+
# Creating simple dataframe for testing basic plots
df <- data.frame(
x = seq(81, 100, by = 1),
@@ -161,7 +165,17 @@ df_absent <- data.frame(
test_that("Testing plotting passes: ", {
- p <- plot_pass(df, type = "sep", outcome = "suc")
+ p <- plot_pass(sb_df, data_type = "statsbomb", type = "sep",
+ outcome = "suc", progressive_pass = TRUE, switch = TRUE,
+ theme = "dark")
+ expect_true(is.ggplot(p))
+
+ p <- plot_pass(sb_df, data_type = "statsbomb", type = "all",
+ outcome = "unsuc", progressive_pass = TRUE,
+ theme = "rose")
+ expect_true(is.ggplot(p))
+
+ p <- plot_pass(df, data_type = "opta", progressive_pass = TRUE)
expect_true(is.ggplot(p))
# testing for plotting on an empty dataframe
@@ -175,7 +189,6 @@ test_that("Testing plotting passes: ", {
})
-
############# |- PLOT_TRENDLINE ################
# Scraping data and selecting only 200 rows
@@ -229,9 +242,6 @@ test_that("Testing plotting trendlines: ", {
})
-
-
-
############# |- PLOT_PIZZA ################
# Scraping data
# data1 <- worldfootballR::fb_player_scouting_report("https://fbref.com/en/players/6928979a/Nicolo-Barella", pos_versus = "primary")
@@ -249,6 +259,12 @@ data2 <- readRDS(d2)
# Dataset for comparison plot
data <- rbind(data1, data2)
+#Dataset for custom pizza plots
+data1_cus <- data1[c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140), ]
+data2_cus <- data2[c(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140), ]
+
+data_cus <- rbind(data1_cus, data2_cus)
+
test_that("Testing plotting pizzas: ", {
# testing for single player plot
p <- suppressWarnings(plot_pizza(
@@ -259,9 +275,25 @@ test_that("Testing plotting pizzas: ", {
expect_true(is.ggplot(p))
+ p <- suppressWarnings(plot_pizza(
+ data = data1_cus, type = "single", template = "custom",
+ color_possession = "green", color_attack = "lightblue", season = "Last 365 Days",
+ color_defense = "#fec44f", theme = "dark"
+ ))
+
+ expect_true(is.ggplot(p))
+
# testing for comparison plot
p <- suppressWarnings(plot_pizza(
- data = data, type = "comparison", template = "midfielder",
+ data = data, type = "comparison", template = "forward",
+ player_1 = "Nicolo Barella", player_2 = "Ilkay Gundogan",
+ season_player_1 = "Last 365 Days", season_player_2 = "Last 365 Days",
+ color_compare = "#90ee90", theme = "white"
+ ))
+ expect_true(is.ggplot(p))
+
+ p <- suppressWarnings(plot_pizza(
+ data = data_cus, type = "comparison", template = "custom",
player_1 = "Nicolo Barella", player_2 = "Ilkay Gundogan",
season_player_1 = "Last 365 Days", season_player_2 = "Last 365 Days",
color_compare = "#90ee90", theme = "black"
@@ -272,6 +304,11 @@ test_that("Testing plotting pizzas: ", {
############# |- PLOT_HEATMAP ################
+
+#StatsBomb dataset
+sbevents <- system.file("testdata", "sbevents.RDS", package = "ggshakeR")
+sb_df <- readRDS(sbevents)
+
# Creating simple dataframe for testing basic plots
df <- data.frame(
x = seq(81, 100, by = 1),
@@ -287,14 +324,20 @@ colnames(df_empty) <- x
# Creating simple dataframe for testing basic plots
df_absent <- data.frame(
- location.x = seq(81, 100, by = 1),
- location.y = seq(81, 100, by = 1),
- pass.end_location.x = seq(51, 70, by = 1)
+ x = seq(81, 100, by = 1),
+ y = seq(81, 100, by = 1),
+ finalX = seq(51, 70, by = 1)
)
test_that("Testing plotting heatmaps: ", {
- p <- plot_heatmap(data = df, type = "hex")
+ p <- plot_heatmap(data = sb_df, data_type = "statsbomb", type = "hex")
+ expect_true(is.ggplot(p))
+
+ p <- plot_heatmap(data = df, data_type = "opta", type = "jdp")
+ expect_true(is.ggplot(p))
+
+ p <- plot_heatmap(data = df, data_type = "opta", type = "density")
expect_true(is.ggplot(p))
# testing for plotting on an empty dataframe
@@ -306,7 +349,6 @@ test_that("Testing plotting heatmaps: ", {
})
-
############# |- CALCULATE_THREAT ################
df <- data.frame(
x = seq(81, 100, by = 1),
@@ -545,7 +587,6 @@ data <- data.frame(
)
)
-
test_that("Testing plotting timelines: ", {
p <- plot_timeline(
data = data, match_year = 2021, team_home = "Manchester United", team_away = "Manchester City",
@@ -558,6 +599,9 @@ test_that("Testing plotting timelines: ", {
############# |- PLOT_CONVEXHULL ################
# Creating dataset
+sbevents <- system.file("testdata", "sbevents.RDS", package = "ggshakeR")
+sb_data <- readRDS(sbevents)
+
names <- c("Jesse", "Jasmine", "Cruz", "Muneeb", "Robert", "Shyanne",
"Angela", "Jennifer", "Ariel", "Austin", "Anaisha")
x <- sample(100)
@@ -593,6 +637,10 @@ test_that("Testing plotting convex hulls: ", {
p <- plot_convexhull(data, data_type = "opta", title_plot = "Test 1")
expect_true(is.ggplot(p))
+ p <- plot_convexhull(sb_data, data_type = "statsbomb", color = "red",
+ theme = "rose")
+ expect_true(is.ggplot(p))
+
# testing for plotting on an empty dataframe
expect_error(plot_convexhull(data_empty, data_type = "opta"),
"The dataset has insufficient columns and/or insufficient data.",
@@ -605,7 +653,6 @@ test_that("Testing plotting convex hulls: ", {
})
-
############# |- PLOT_VORONOI ################
# Creating simple dataframe for testing basic plots
x <- sample.int(100, 10)
@@ -653,6 +700,9 @@ test_that("Testing plotting voronoi plots: ", {
############# |- PLOT_PASSNET ################
# Create Dataset
+sbevents <- system.file("testdata", "sbevents.RDS", package = "ggshakeR")
+sb_data <- readRDS(sbevents)
+
names <- c("Adam", "Tony", "Avery", "Darrick", "Zachary", "Zachary", "Daisha",
"Maliha", "Candace", "Jeffrey", "Abdul Khaliq", "Andrew", "Raafi",
"Jalyn", "Rochelle", "Safwaan", "Angel", "Tawasa", "Olympia", "Nikko",
@@ -702,7 +752,12 @@ colnames(data_empty) <- x
test_that("Testing plotting pass networks: ", {
#testing
- p <- plot_passnet(data, data_type = "opta", team_name = "Team 1", subtitle_plot = "Test 1")
+ p <- plot_passnet(data, data_type = "opta", scale_stat = "xT", scale_color = "blue",
+ team_name = "Team 1", flip = FALSE, subtitle_plot = "Test 1", theme = "dark")
+ expect_true(is.ggplot(p))
+
+ p <- plot_passnet(sb_data, data_type = "statsbomb", scale_stat = "EPV", scale_color = "red",
+ team_name = "Barcelona", flip = TRUE, theme = "light")
expect_true(is.ggplot(p))
# testing for plotting on an empty dataframe