Retrosheet Data

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Retrosheet Data

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

function(team){
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
   do.call("rbind",lapply(1:length(P),get_plays))
}
all_plays <- do.call("rbind",lapply(Teams[1:30],get_team_plays))
head(all_plays,10)

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

head(all_plays,10)
    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.

Thanks,
Philip Heinrich

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.