Closed jsst28 closed 5 years ago
Hey @jsst28 - no worries about not knowing, I should probably (and will) add an example of how to use it in the README.
The path
argument is just specifying where you want to save the file on your computer. So it should be something like this:
write_lineups(mylineups, path = "/home/user/mydata.csv")
or if you are on Windows
write_lineups(mylineups, path = "C:\My Documents\mylineups.csv")
Does that help or are you still getting an error? If you are still having trouble paste the command you are using in here and I'll try and help debug.
I'm still getting an error. I've tried doubling the backward slashes but that didn't work and neither did trying to use file.path.
write_lineups(lineups, path = "C:\My Documents\lineups.csv") Error: '\M' is an unrecognized escape in character string starting ""C:\M"
write_lineups(lineups, path = "C:\My Documents\lineups.csv") Error in split.default(lineups, lineups[["lineup"]]) : group length is 0 but data length > 0
write_lineups(lineups, file.path = 'c:','My Documents','lineups.csv') Error in split.default(lineups, lineups[["lineup"]]) : group length is 0 but data length > 0
Yep the first error in the list you posted is due to not using double backwards slashes. The third one won't work because there is no argument called file.path
in the function. The second one looks good but apparently there is some issue with the lineups
data. Can you paste the first few rows of lineups
? Also what sport and dfs optimizer did you use?
I'm using FD NHL Optimizer. Here's the first tibble: lineups [[1]]
row_id player_id player team position salary fpts_avg fpts_proj
Ok! I'm able to reproduce the error. I've made a quick fix. Can you re-install the package using my new fix?
devtools::install_github("dfs-with-r/coach", ref = "fix-write-lineups")
Then something like this should work. You have to specify the site
and sport
in the new function.
library(coach)
nhl <- read_fd("salaries.csv")
model <- model_fd_nhl(nhl)
lineups <- optimize_generic(nhl, model)
write_lineups(lineups, "mylineups.csv", site = "fanduel", sport = "nhl")
The output should look like this. The order of the positions is important (C,C,W,W,W,W,D,D,G)
C | C | W | W | W | W | D | D | G |
---|---|---|---|---|---|---|---|---|
23625-58926 | 23625-8535 | 23625-8718 | 23625-12410 | 23625-62723 | 23625-66675 | 23625-8426 | 23625-8467 | 23625-8612 |
23625-58926 | 23625-8535 | 23625-43214 | 23625-12410 | 23625-62723 | 23625-66675 | 23625-8426 | 23625-8467 | 23625-8612 |
23625-58926 | 23625-8535 | 23625-12410 | 23625-37968 | 23625-79857 | 23625-79820 | 23625-9015 | 23625-8467 | 23625-8612 |
That fixed the issue! Thank you very much!
I'm assuming I'm missing something when I try to use the write_lineups function. I either get: "Error in split.default(lineups, lineups[["lineup"]]) : group length is 0 but data length > 0" or "Error: '...' used in an incorrect context"
I feel like an idiot for asking, but what should I placing with regards to the "NULL" and after the comma within this code. I've tried everything I can think of and can't figure it out. write_lineups(lineups, path = NULL, ...)