Closed tdemmer18 closed 5 years ago
Hmm.. This looks like the exact same issue as #6. I'll take a look
This is working fine for me. When I run write_lineups()
I get back:
C | C | W | W | W | D | D | G | UTIL |
---|---|---|---|---|---|---|---|---|
12146192 | 12146242 | 12146678 | 12146550 | 12146558 | 12147206 | 12147110 | 12147657 | 12146658 |
12146192 | 12146242 | 12146498 | 12146550 | 12146558 | 12147202 | 12147206 | 12147657 | 12146658 |
12146192 | 12146242 | 12146498 | 12146550 | 12146558 | 12147206 | 12147204 | 12147657 | 12146658 |
Can you verify your version of coach? When you type devtools::session_info()
what does the line for coach return? It should be:
coach * 0.0.1 2019-02-20 [1] Github (dfs-with-r/coach@4904527)
coach * 0.0.1 2019-02-15 [1] Github (zamorarr/ coach@78c5a2a)
**without the space after zamorarr/
That looks to have a different commit hash than mine (4904527 vs 78c5a2a) . Can you try re-installing with devtools::install_github("dfs-with-r/coach")
again?
If you look at the commit history you'll see that your version of the code is much older. The write_lineups()
fix should be in the most recent version.
Okay, I was able to get it to update, but now when I run it, I get the error below. coach * 0.0.1 2019-02-26 [1] Github (dfs-with-r/ coach@4904527)
Error in split.default(lineups, lineups[["lineup"]]) : group length is 0 but data length > 0
Ok it looks like you are up to date. That error is very strange since that line split(lineups, lineups[["lineup"]]))
should no longer exist in the code.
if you type write_lineups
in your R console (without any parenthesis) it should print out the source code for the function. It should look like this:
function (lineups, path = NULL, site = c("draftkings", "fanduel",
"fantasydraft"), sport = c("nfl", "mlb", "nba", "nhl", "nascar"),
...)
{
converted_lineups <- lapply(lineups, convert_lineup, site,
sport, ...)
df <- do.call(rbind, converted_lineups)
if (!is.null(path)) {
utils::write.csv(df, file = path, row.names = FALSE,
quote = FALSE)
}
df
}
If it starts with a line that looks like split(lineups, ...
then somehow it is still loading the old version of the library.
Okay it worked. I restarted rstudio and re-ran everything and it worked. Thanks for the help and great job with the package. I'm still relatively new to R so I appreciate the help.
no problem @tdemmer18. Thanks for using the package. Feel free to post any other questions in the future!
Here is the error:
Error in split.default(lineups, lineups[["lineup"]]) : group length is 0 but data length > 0
Here is the code I ran. The draftkings file is for today 2019-02-26, full game slate.
devtools::install_github("dfs-with-r/coach") library(coach)
data <- read_dk("~/Downloads/DKSalaries.csv")
set.seed(100) n <- nrow(data) data$fpts_proj <- rnorm(n, data$fpts_avg) data
model <- model_dk_nhl(data)
lineups <- optimize_generic(data, model) lineups
write_lineups(lineups, "mylineups.csv", site = "draftkings", sport = "nhl")