Closed rlindholm closed 5 years ago
Oh yeah totally forgot about this, thanks for checking this.
@rlindholm pt_id is the conversion of play_type. See line 31/33. It handles the conversion regardless.
Sorry, still working on that one, trying to fix this function call:
cfb_pbp_data(week=8, team='Florida State', year=2018) Error in paste0(play_base_url, "year=", year, "&week=", week, "&playType=", : object 'pt_id' not found
It only enters that first statement if play_type is not null. With a call with a null play_type, pt_id never gets set and it breaks.
Oh yeah, I see that now. fixing it right now.
I'm going to merge this and then make the change to fix that.
I've got one more fix in that function hang on one sec.
just hit me with it on here, and i'll do it on my git branch
if (is.null(play_type) & is.null(team)) {
# no play type, no team
full_url <- paste0(play_base_url, "year=", year, "&week=", week)
} else{
#team, no play_type
if (is.null(play_type)) {
full_url <-
paste0(play_base_url,
"year=",
year,
"&week=",
week,
"&team=",
URLencode(team, reserved = T))
} else if (is.null(team)) {
# no team, play_type
full_url <-
paste0(
play_base_url,
"year=",
year,
"&week=",
week,
"&playType=",
URLencode(play_type, reserved = T)
)
} else{
# team & play type
full_url <-
paste0(
play_base_url,
"year=",
year,
"&week=",
week,
"&team=",
URLencode(team, reserved = T),
"&playType=",
play_type
)
}
}
raw_play_df <- fromJSON(full_url)
raw_play_df <- do.call(data.frame, raw_play_df)
play_df <- raw_play_df
return(play_df)
}```
The way it is currently, it's passing in null params. After the play_type fix it wasn't correctly bringing back Florida State's week 8. It was bringing back week 8 for a different team.
Yep, I saw that too when debugging. Thanks for the help/debugging.
I'll update in a few minutes. I can add you on as a contributor on the pkg, just hit me with some details name/email.
Sure! Ryan Lindholm and ryan.lindholm@outlook.com. Thanks!
Looks like you might have updated the name of the df recently. This gets the function working again.