[R] Retrosheet Data

Philip herd_dog @end|ng |rom cox@net
Thu Oct 8 19:52:47 CEST 2020

Have used Jim Albert’s code to extract baseball data from Retrosheet.

P <- getRetrosheet("play",2013,team)
   get_plays <- function(j) data.frame(Game=P[[j]]$id[1],P[[j]]$play)#from $id and $play section of retrosheet data
all_plays <- do.call("rbind",lapply(Teams[1:30],get_team_plays))

I get the following six variables from the play section of the retrosheet data:

    Game                    inning team  retroID        count  pitches play
1  TEX201304050      1         0        troum001    01      CX         63/G
2  TEX201304050      1         0        aybae001    12      TBFX     7/F
3  TEX201304050      1         0        pujoa001     00      X           6/L
4  TEX201304050      1         1        kinsi001      02      FCX        53/G   

Very useful but I would also like to access the $info, $start, $sub, and $data sections.  I have tried replacing $play in the line below with $info, $start, etc. without success.  

 get_plays <- function(j) data.frame(Game=P[[j]]$id[1],P[[j]]$play) with 

get_plays <- function(j) data.frame(Game=P[[j]]$id[1],P[[j]]$info)

I keep getting the same Game, inning, team, etc. data.

Can anyone give me some direction.

Philip Heinrich

	[[alternative HTML version deleted]]

More information about the R-help mailing list