nflverse / nfldata

NFL Data (by Lee Sharpe)
263 stars 72 forks source link

Baldwin Mutations Error - Passer EPA #9

Closed z-feldman closed 4 years ago

z-feldman commented 4 years ago

Hey Lee,

Got this error when running of playdata:

Line of code ran

if (baldwin_mutations) plays <- apply_baldwin_mutations(plays)

[1] "2020-03-16 12:30:14: Applying Ben Baldwin mutations"

Error

Error in ifelse(!is.na(passer_epa), passer_epa, ifelse(!is.na(epa) & pass == : object 'passer_epa' not found Called from: ifelse(!is.na(passer_epa), passer_epa, ifelse(!is.na(epa) & pass == 1, epa, NA)) Browse[1]> Q

Looks like it's throwing the error on line 222-225 in plays-functions where p and wr_fumbled are joined then passer_epa is mutated. If I find the error I'll let you know thanks

Zach

z-feldman commented 4 years ago

lol I didn't know hashtag made the text big and bold I was trying to do an R comment

z-feldman commented 4 years ago

It looks like after the join of p and wr_fumbled, it's trying to mutate passer epa before it checks if passer_epa.y exists. I ran the if statement in plays-functions line 227, then ran the mutate in line 224 and did not get an error, so I think that's the issue.

leesharpe commented 4 years ago

This has now been resolved, there's an explicit check for passer_epa.y before p is changed.