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

getData — Error in bind_rows_(x, .id) : Column balls can't be converted from character to integer #111

Open
ssp3nc3r opened this issue Nov 16, 2017 · 4 comments

Comments

@ssp3nc3r
Copy link

ssp3nc3r commented Nov 16, 2017

I received this error when retrieving data for the 2012 regular season. When I change the line of code in getData(...) from,

out <- dplyr::bind_rows(ds.list)

to

out <- do.call(rbind, lapply(ds.list, data.frame, stringsAsFactors=FALSE))

the code completes without an error, though balls and strikes are of type character so they need to be converted to integer: out <- transform(out, balls = as.integer(balls), strikes = as.integer(strikes))

@beanumber
Copy link
Owner

Hmm...OK, thanks. Can you identify a particular day in 2012, or better yet, a particular game in which the problem arises? That would be helpful in debugging.

@ssp3nc3r
Copy link
Author

No, sorry. I scraped the entire regular season at once. The bind_rows operates on the entire list at once, so it may take a lot of trial and error to find the offending game or games. I just re-ran the function, up to assignment to ds.list, so that I could have the data saved, and from that figured out the code I shared above which fixed the error.

@znmeb
Copy link
Contributor

znmeb commented Mar 25, 2018

I'm getting an empty data frame from out <- dplyr::bind_rows(ds.list) now. I've forked the repo and I'm in the process of troubleshooting. gd.list looks OK but ds.list has nulls for all the data.

> library(openWAR)
> test <- getData("2018-03-24")

Retrieving data from 2018-03-24 ...

...found 16 games
[snip]
Error in grouped_df_impl(data, unname(vars), drop) : 
  Column `gameId` is unknown
In addition: Warning message:
In .Internal(get(x, envir, mode, inherits)) :

It's crashing trying to drop suspended games, but ds.list is messed up before it gets there and the out data frame is empty.
screenshot from 2018-03-25 13-08-55
screenshot from 2018-03-25 13-09-24

I think this line is wrong: ds.list <- lapply(gd.list, "[[", "ds") but I'm not sure what's supposed to be there.

@james-ingold
Copy link

@znmeb I was getting the same issue. It looks like MLB game day is including the day_xx portion of the url with the game ids now. I made the following pull request which fixes the issue
#114

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

4 participants