In many cases, we may want to search for a specific player, stadium, or team. The search_gids()
function provide limited functionality for such searches. Arguments include; team=NULL, start=NULL, end=NULL, venue=NULL, game_type=NULL, home_only=FALSE, away_only=FALSE.
Find only regular season games for the 2016 season.
library(mlbgameday) gids <- search_gids(start = "2016-01-01", end = "2017-01-01", game_type = "r")
Find only regular season games played at Wrigley Field in 2016.
library(mlbgameday) gids <- search_gids(start = "2016-01-01", end = "2017-01-01", game_type = "r", venue = "Wrigley Field") # This also works with a "fuzzy search" gids <- search_gids(start = "2016-01-01", end = "2017-01-01", game_type = "r", venue = "Wrigley")
The game_type =
argument accects the following:
"r" = regular season
"d" = divisional playoffs
"l" = leauge playoffs
"w" = World Series
"a" = all-star games
"s" = spring training
"e" = exabition game
Find only home games played by the Cleveland Indians in the regular season (regardless of stadium).
library(mlbgameday) gids <- search_gids(team = "indians", start = "2015-01-01", end = "2015-01-01", game_type = "r")
The search_gids()
function performs a "fuzzy match," on names of teams and ball parks. For example, we don't have to type out "Oriole Park at Camden Yards," simply "Camden" or "Camden Yards" will work.
library(mlbgameday) # This workds. gids <- search_gids(team = "orioles", start = "2016-01-01", end = "2017-01-01", venue = "Oriole Park at Camden Yards") # This also works. gids <- search_gids(team = "orioles", start = "2016-01-01", end = "2017-01-01", venue = "Camden")
Be careful about venue changes or venue name changes. For example, "Marlins Park" opened in 2012, so the follwoing will not work.
library(mlbgameday) gids <- search_gids(team = "marlins", start = "2010-01-01", end = "2011-01-01", venue = "Marlins Park")
Instead, we would have to use the name of the old stadium. If we're not sure, the safest way would be to use home_only = TRUE
.
library(mlbgameday) gids <- search_gids(team = "marlins", start = "2010-01-01", end = "2011-01-01", venue = "Sun Life Stadium") # This will return the same result if we don't know the name of the stadium. gids <- search_gids(team = "marlins", start = "2010-01-01", end = "2011-01-01", home_only = TRUE, game_type = "r")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.