Quantcast
Channel: DECISION STATS » Application programming interface
Viewing all articles
Browse latest Browse all 7

Using R for Cricket Analysis #rstats

$
0
0

ESPN Crincinfo is the best site for cricket data, and using the XML package we can easily scrape and manipulate data

Here is the code.

library(XML)
url="http://stats.espncricinfo.com/ci/engine/stats/index.html?class=1;team=6;template=results;type=batting"
#Note I can also break the url string and use paste command to modify this url with parameters
tables=readHTMLTable(url)
tables$"Overall figures"

#Now see this- since I only got 50 results in each page, I look at the url of next page

table1=tables$"Overall figures"
url="http://stats.espncricinfo.com/ci/engine/stats/index.html?class=1;page=2;team=6;template=results;type=batting"
tables=readHTMLTable(url)
table2=tables$"Overall figures"

#Now I need to join these two tables vertically

table3=rbind(table1,table2)

Note-I can also automate the web scraping .
Now the data is within R, we can use something like Deducer to visualize.
Created by Pretty R at inside-R.org

Tagged: Application programming interface, Data Formats, Free, Hosting, Markup Languages, R, rstats, Uniform Resource Locator, Web Design and Development, xml

Viewing all articles
Browse latest Browse all 7

Latest Images

Trending Articles



Latest Images