[R] Analyze XML data

skyjo srjohnson85 at hotmail.com
Fri Nov 13 23:53:07 CET 2009


I would like to analyze XML data from MLB's website. I do the following
steps:

library(XML)
dat<-"http://gd2.mlb.com/components/game/mlb/year_2007/month_05/day_02/gid_2007_05_02_arimlb_lanmlb_1/inning/inning_1.xml"
example<- xmlTreeParse(dat, useInternalNodes=T)
ex<-xpathApply(example, "//inning", xmlToList)      #could also use
"//atbat"

This brings information from the first inning of the Arizona/LA game played
on 5/2/2007 into R.
Now that I have it in R, I don't understand how to 'get at' the data. For
example, how could I calculate the average start speed (
[[1]]$top$atbat$pitch["start_speed"] ) of all pitches thrown in the inning? 

Thanks, 
Skyler



-- 
View this message in context: http://old.nabble.com/Analyze-XML-data-tp26344817p26344817.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list