Wednesday, March 18, 2015

How to plot a map using "R"

This is my first attempt of using R. The final intention is to have heat map for certain type of events that occur in Dubai.

To plot a map using R studio, google maps / open street map library is required. To install Google map:
>  install.packages("ggmap")
>  install.packages ("ggplot2")
>  install.packages("maps")

Note: If you want to install into specific file location then:
> install.packages("maps", lib="C:/Users/xxxx/Documents/R/win-library/3.1")

Once these packages are installed, A map of Dubai is obtained with just five lines of R code (including the loading of packages.)

> library("ggplot2")
> library("ggmap")
> library("maps")
> map <- get_map(location = 'Dubai', zoom=11)
Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Dubai&zoom=11&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Dubai&sensor=false
> ggmap(map)



Saturday, January 31, 2015

Cricket World Cup Centuries


  • A total of 127 centuries has been scored in World cup. 
  • On an average 13 centuries have been scored in each world cup. While in the last 3 world cups the average no of centuries is 22.
  • Only 2 centuries were scored in 1979 world cup and both of them were by West Indies.
  • 24 centuries were scored in the 2011 world cup, the most for one single world cup



  • Australia has scored 22 world cup centuries, the most by any team. While New Zealand were at the receiving end allowing teams to score 16 centuries against them
  • Except for 1999 World cup, West Indies has scored century in every World Cup.





Matches involving Pakistan has witnessed 16 centuries, but only 3 were against them



India and Australia has scored a century in every 4 matches played





In 2011 World cup, one century was scored in every second game.The worst ratio is for 1979 world cup: One in every 8 matches played
Sub-Continent has been the best for batsmen, every 2nd match a century has been scored.










Tuesday, December 30, 2014

Cricket - Batting averages can lie

Continuing on Rohit Sharma…


His test record looks good with batting average of 40.71. Virat Kohli crossed 40 average mark only after 30th test match. 


Rohit Sharma has two not outs in his career 111 n.o and 31 n.o. If those two innings are excluded then his average falls down to 30.57. Now by considering those two innings and ignoring the not outs his average for 16 innings is 35.63. Even that seems to be quiet good for a batsman who has played 9 test matches only.

Further, analyzing his 16 innings statistically...


Mean - 36 is average number of runs he has scored in each innings. That means to say we can expect him to score 36 runs every innings.
Median - He has scores less than 22 in 50% (8 innings) of the innings he has played.
Mode - He has got out on 6 runs 3 times.
Standard deviation - He has scored runs anywhere between 0 to 82 runs in most of the innings.


This graph clearly suggest his two innings are the outliers and incidentally these two innings he has batted in India.

Interestingly these two innings account to 49.5% of the runs he has scored.

If we ignore these two innings that will constitute his overseas record.


His graph here is more consistent.




His average (mean) value dips to 20 runs per innings.

While his median value doesn't have much of an impact it is 20, i.e., he has 50% (7 innings) scores of below 20 runs per innings he has played. That is why median gives true indication than average which can go up and down based on one big innings or even more fluctuate when it is a big innings not out.

As the outliers are removed, his standard deviation also improves 20 runs. That means most of his scores are between 0 to 40 runs with mean .

The above analysis clearly shows that only average doesn't qualify to be a right measure of a batsman.

Tuesday, December 23, 2014

Rohit Sharma - Mr Talent on Indian Soil

Rohit Sharma started his career way back in 2007. He was part of the 2007 t-20 world cup winning team. Virat Kohli in 2007 was just an under 19 player and only in 2008, he captained India in U-19 world cup. Ajinkya Rahane had not even made his ranji trophy debut until 2007 (He made his Ranji Trophy debut for his first-class side Mumbai in the 2007/2008 season).

Today, both Kohli and Rahane are part of Indian test team and Rohit Sharma is the most talented batsman in making.

Rohit Sharma’s Test and ODI records seems to be good at one glance with both average around 40 as a batsman.


Test Matches


Out of the 9 matches he has played 2 has been in India. If those 2 are not considered then his batting average outside India is just 20 with a highest score of 72.

Outside India


9 is just a sample size. Let us consider his ODI records.  He has played 126 ODI matches with a batting average of 37.89 which is decent.

He has decent record against most of the countries except South Africa (Ignoring Bangladesh, Afghanistan, Ireland and Hong Kong). He averages 39.24

In India, he has scored 2 double centuries and therefore his records in India are amazing. He has scored 1443 runs in 28 matches at an average of 65.59

Outside India he has done well in West Indies & Zimbabwe with over 50 + averages along with 2 centuries in West Indies

Outside India he has scored 2309 runs at an average of 29.98. If West Indies and Zimbabwe are not considered this averages dip below 24

These numbers just indicate that Mr. Talent is awesome on Indian Pitches, but outside India he lacks the talent!


Batting average comparison with Suresh Raina & Yuvraj Singh



Sunday, December 21, 2014

Is India ready for sports other than cricket?

This year saw advent of many premier club based sports in India. There was something more to cheer about for the city based fans than just cheering for cricket. Pro Kabaddi, Indian Super League (Football) saw huge fan following throughout the country. Does such leagues / sports really challenge cricket?

Part 1 – Kabaddi trends in 2014

Based on the Google trend stats based on search:
The Pro Kabaddi interest was at peak during the games played in the month of July.


The regional interest was mainly form the cities that had teams representing them. A surprise in top 10 cities, at No.5 is “Sucre”, Capital of Bolivia.

When data of 2013 and 2014 are compared, the commencement of Pro Kabaddi league has definitely gained interest of people in Kabaddi in general.


Kabaddi is well followed in Northern part of India, esp in Punjab and also in the Punjab region in Pakistan. The advancement of ProKabaddi league has successfully gained interest in the game in other parts of India, as Pune was among the top 10 cities that searched for Kabaddi in 2014.

Regional Interest in Kabaddi in 2013


Regional Interest in Kabaddi in 2014

Tuesday, December 16, 2014

RCB Salary structure from a numerical view

During last season they have spent their entire pocket of ₹ 60 crores to buy 21 player
The average salary for each player is ₹ 2,85,71,429
There is huge salary disparity among the 21 player, as the median is ₹ 90,00,000 with a standard deviation of  ₹ 4,19,07,576

75% of the team i.e., 16 among 21 players draw salary less than ₹ 2,40,00,000 which is less than the average salary





Now that they have released Yuvraj Singh, Muttiah Muralitharan, Albie Morkel, Ravi Rampaul, Sachin Rana, Shadab Jakati, Tanmay Mishra, they have ₹  18,80,00,000 remaining in their kitty
Currently they have spent of ₹ 41 crores to buy 14 player
The average salary for each player is ₹ 2,94,28,571
There is still huge salary disparity among these 14 player, as the median is ₹ 95,00,000 with a standard deviation of  ₹ 3,92,18,644
71% of the team i.e., 10 among 14 players draw salary less than ₹  2,69,00,000 which is less than the average salary. The rest 4 players earn an average salary of ₹ 8,62,50,000




Now with their remaining pockets and considering their average spending, it can be expected that they will buy 6 more players during the next auction.




Thursday, December 11, 2014

Virat Kohli - On a long way

Virat Kohli has had a great start to his career. In the 140 ODI matches that he has played, he has scored over 5700 runs at an average of 51.24. Especially while chasing a target he’s been exceptional and consistent. But his test statistics doesn’t seem to project the same level of greatness as his ODI records.

In the 29 test matches (before India vs Australia series 2014) he has played so far he has scored 1855 runs at an average of 39.46. This really looks bad when compared to his ODI average of 51.24. How does it look when it is compared with the greats after playing 29 test matches?

As of today (12th Dec, 2014) the following are top six players based on runs scored over their career



Based on the number of runs scored in first 29 matches, Virat Kohli is better than Kallis & Ponting. He has scored more centuries than them and also more than Dravid, Sangakkara, & Lara. But Virat fails miserably in the average sections




India batsmen are generally compared on how they fare outside India. Kohli has played 31 innings outside India, and when comparing that with first 31 innings of other great India players, he is some way below the rest.




Kohli’s has scored century on his captaincy debut and in good hope he should be able to keep his records along or above the rest of the greats.