Closed iamrafael8 closed 6 years ago
I'm not encountering the same error as you. This code example above was meant for the Serbia vs Costa Rica match, did you change the game id? Because other games could have own-goals which would be another type for shot_result causing it to be 5 instead of 4.
Yes exactly, I have usedd Uruguay vs Russia which is not working because of the own goals
Okay, then this isn't an issue with fcscrapR itself (unless the own goals are missing, which has been pointed out in another issue). Instead this is more of how to use ggplot and setting your color scale, with the ow_goal you now now 5 types of shot_result so you need to add another color to the vector inside scale_fill_manual() or use a different version scalefill such as scale_fillbrewer(palette = "Set1") for example. Here's more info: http://www.cookbook-r.com/Graphs/Colors(ggplot2)/
The number of colors shall be 5 instead of 4 in the example code
library(ggplot2) srb_crc_commentary %>% dplyr::filter(!is.na(shot_result)) %>% ggplot(aes(x = shot_by_team, fill = shot_result)) + geom_bar() + labs(x = "Team", y = "Count", fill = "Shot result", title = "Distribution of shot attempts for Costa Rica vs Serbia by result", caption = "Data from ESPN, accessed with fcscrapR") + scale_fill_manual(values = c("darkorange", "darkblue", "darkred", "darkcyan")) + theme_bw()