Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getallinfo() fails in some cases due to first element of myList being NULL #2

Open
JoGall opened this issue Feb 2, 2019 · 0 comments

Comments

@JoGall
Copy link

JoGall commented Feb 2, 2019

I'd make this a pull request but I'm running a much different fork of the package for use with R <v5.0.

getallinfo() is failing currently for the latest FA WSL fixtures due to some weirdness in match_id == 19790:

Reprex:

library(dplyr)
library(StatsBombR)

# get all available fixtures from StatsBomb
fixture <- FreeMatches(37) %>% 
  filter(match_id == 19790)

getallinfo(fixture)

# Error in matrix(ncol = ncol(myList[[1]]), nrow = 1) : non-numeric matrix extent

Going through step-by-step, it's functions goalkeeperinfo() and freezeframeinfo() that fail; in both cases seems to be due to the first entry of Shots.FF being NULL, causing the fixnull function to fail.

A simple fix is to use the first non-null of myList in fixnull, changing line 13 of goalkeeperinfo.R and line 23 of freezeframeinfo from:

return(setNames(data.frame(matrix(ncol = ncol(myList[[1]]), nrow = 1)), names(myList[[1]])))

to:

return(setNames(data.frame(matrix(ncol = ncol(myList[lengths(myList) != 0][[1]]), nrow = 1)), names(myList[lengths(myList) != 0][[1]])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant