BillPetti/baseballr

"Invalid arguments or no team results available" for MIA, WSN, LAD, CLE, CHA for 2022

Opened this issue · 4 comments

Describe the bug
No results for 5 teams using the bref_team_results function.: Marlins, Nats, Dodgers, Guardians, and White Sox.

To Reproduce

The following code provides results for only 25 teams. The teams listed above
teams<-c("NYM", "CHC", "ATL", "CIN", "SLN", "LAA", "BAL", "MIN",
"OAK", "TEX", "TOR", "ARI", "PIT", "SEA", "HOU", "KCR", "TBR",
"COL", "MIL", "PHI", "SDN", "SFN", "BOS", "DET", "NYA","LAD",
"CHA", "CLE", "WSN", "MIA")


```{r For Loop for 2022 Season Results}
mlb_results<-data.frame()

for (x in teams) {
  season_results<-bref_team_results(Tm=x, year = 2022) 
  loop<-data.frame(season_results)
  mlb_results<-rbind(mlb_results,loop)
}
2023-03-14 09:58:53: Invalid arguments or no team results data available!
2023-03-14 09:58:54: Invalid arguments or no team results data available!
2023-03-14 09:58:54: Invalid arguments or no team results data available!
2023-03-14 09:58:54: Invalid arguments or no team results data available!
2023-03-14 09:58:54: Invalid arguments or no team results data available!
2023-03-14 09:58:54: Invalid arguments or no team results data available!
2023-03-14 09:58:54: Invalid arguments or no team results data available!
2023-03-14 09:58:55: Invalid arguments or no team results data available!
2023-03-14 09:58:55: Invalid arguments or no team results data available!
2023-03-14 09:58:55: Invalid arguments or no team results data available!
2023-03-14 09:58:55: Invalid arguments or no team results data available!
2023-03-14 09:58:56: Invalid arguments or no team results data available!
2023-03-14 09:58:56: Invalid arguments or no team results data available!
2023-03-14 09:58:56: Invalid arguments or no team results data available!
2023-03-14 09:58:56: Invalid arguments or no team results data available!
2023-03-14 09:58:56: Invalid arguments or no team results data available!
2023-03-14 09:58:56: Invalid arguments or no team results data available!
2023-03-14 09:58:57: Invalid arguments or no team results data available!
2023-03-14 09:58:57: Invalid arguments or no team results data available!
2023-03-14 09:58:57: Invalid arguments or no team results data available!
2023-03-14 09:58:57: Invalid arguments or no team results data available!
2023-03-14 09:58:57: Invalid arguments or no team results data available!
2023-03-14 09:58:57: Invalid arguments or no team results data available!
2023-03-14 09:58:58: Invalid arguments or no team results data available!
2023-03-14 09:58:58: Invalid arguments or no team results data available!
2023-03-14 09:58:58: Invalid arguments or no team results data available!
2023-03-14 09:58:58: Invalid arguments or no team results data available!
2023-03-14 09:58:58: Invalid arguments or no team results data available!
2023-03-14 09:58:58: Invalid arguments or no team results data available!
2023-03-14 09:58:59: Invalid arguments or no team results data available!
**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
 - OS: windows
 - Browser [e.g. chrome, safari]
 - Version R version 4.2.2, baseballr package 1.3.0

**Smartphone (please complete the following information):**
 - Device: [e.g. iPhone6]
 - OS: [e.g. iOS8.1]
 - Browser [e.g. stock browser, safari]
 - Version [e.g. 22]

**Additional context**
Add any other context about the problem here.

My guess is Baseball Reference might've rate limited your requests.

I ran this below without any issues.

library(tidyverse)
library(baseballr)

teams<-c("NYM", "CHC", "ATL", "CIN", "SLN", "LAA", "BAL", "MIN",
         "OAK", "TEX", "TOR", "ARI", "PIT", "SEA", "HOU", "KCR", "TBR",
         "COL", "MIL", "PHI", "SDN", "SFN", "BOS", "DET", "NYA","LAD",
         "CHA", "CLE", "WSN", "MIA")

mlb_results<-data.frame()

for (x in teams) {
  Sys.sleep(runif(1, max = 7))
  print(x)
  
  season_results<-bref_team_results(Tm=x, year = 2022) 
  loop<-data.frame(season_results)
  mlb_results<-rbind(mlb_results,loop)
}

I think it was likely a temporary limitation. Have you tried updating the package and then running the example that I included to see if that works for you?