abhiamishra / ggshakeR

An analysis and visualization R package that works with publicly available soccer data
https://abhiamishra.github.io/ggshakeR/
MIT License
112 stars 14 forks source link

Pizza plot won't plot #66

Closed sjkrrrch closed 2 years ago

sjkrrrch commented 2 years ago

Doing a comparison pizza plot and I keep getting an error returned:

Error in if (0 <= angle & angle < 90) { : the condition has length > 1

I think this has to do with how the function is handling vectorized objects

harshkrishna17 commented 2 years ago

Hey @sjkrrrch. Are you working on a mac or windows?

harshkrishna17 commented 2 years ago

Could you also please send a screenshot of the code you are using

szfh commented 2 years ago

Hi @harshkrishna17 I am also getting this error by running the example code.

library(tidyverse)
library(worldfootballR)
library(ggshakeR)

single_player <- fb_player_scouting_report("https://fbref.com/en/players/f586779e/Tammy-Abraham", pos_versus = "primary")

pizza <- plot_pizza(data = single_player, type = "single", template = "forward", 
                    colour_poss = "#41ab5d", colour_att = "#fec44f", season = "Last 365 Days", 
                    colour_def = "#de2d26", theme = "dark")
pizza
Error in if (0 <= angle & angle < 90) { : the condition has length > 1

image

It's caused by the angle argument to axis.text.x = element_text(size = 12, colour = colorText, angle = ang), I tried to see what was wrong but the ang vector seems to be right and it should accept a vector of angles ...

This is on Windows.

harshkrishna17 commented 2 years ago

Could you try to reinstall the package and run the code again? I'll also try to figure out what's wrong.

szfh commented 2 years ago

Done a hard reinstall and still the same

> sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8   
[3] LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] ggtext_0.1.1              ggshakeR_0.1.2            worldfootballR_0.5.3.4000
 [4] forcats_0.5.1             stringr_1.4.0             dplyr_1.0.9              
 [7] purrr_0.3.4               readr_2.1.2               tidyr_1.2.0              
[10] tibble_3.1.7              ggplot2_3.3.6             tidyverse_1.3.1          
[13] devtools_2.4.3            usethis_2.1.6            
harshkrishna17 commented 2 years ago

Thanks! I'll get back to you

harshkrishna17 commented 2 years ago

Hey @sjkrrrch @szfh we've pushed a commit that fixes this issue with the pizza_plot function. It was due to a change in the way ggplot2 accepts an angle vector in R version 4.2.0. You can reinstall the ggshakeR package to get the latest version of the function that works.

harshkrishna17 commented 2 years ago

Another small thing to mention is that a few of the parameter names have been changed wrt to our new version release.

szfh commented 2 years ago

Thank you! Thought it might be an R version thing. Works for me now with v4.2.0.

harshkrishna17 commented 2 years ago

@szfh Great to hear!

abhiamishra commented 2 years ago

Issue was completed and fixed by @harshkrishna17.