This year H1N1 virus spread like a wildfire in India reporting many cases from different states. Many people have died. Some say lack of adequate medicine supplies is the reason, some say the virus mutated. Anyway, I didn’t dig into too much detail except pointing which states have maximum reported cases till 22nd February 2015.

Load the data

h1n1
##          State Reported.cases Deaths
## 1    Rajasthan           4318    212
## 2      Gujarat           2886    197
## 3        Delhi           2060      9
## 4  Maharashtra            801     92
## 5    Telangana           1233     49
## 6           TN            225      8
## 7       Punjab            105     31
## 8       Andhra             72      9
## 9           UP            165      6
## 10 Chhatisgarh             27      3
## 11         Goa              7      1
## 12         J&K            109      4
## 13          HP             14      2
## 14      Kerala             25      4
## 15      Odisha              9      2
## 16          WB             58      3

We’ll do some data manipulation and descriptive statistics.

require(dplyr)

Arrange the data by reported cases

h1n1 <- arrange(h1n1, desc(Reported.cases))
h1n1
##          State Reported.cases Deaths
## 1    Rajasthan           4318    212
## 2      Gujarat           2886    197
## 3        Delhi           2060      9
## 4    Telangana           1233     49
## 5  Maharashtra            801     92
## 6           TN            225      8
## 7           UP            165      6
## 8          J&K            109      4
## 9       Punjab            105     31
## 10      Andhra             72      9
## 11          WB             58      3
## 12 Chhatisgarh             27      3
## 13      Kerala             25      4
## 14          HP             14      2
## 15      Odisha              9      2
## 16         Goa              7      1
# Total reported cases
sum(h1n1$Reported.cases)
## [1] 12114
# Total Death
sum(h1n1$Deaths)
## [1] 632

The top 5 states with maximum reported cases are Rajasthan, Gujarat, Delhi, Telangana and Maharashtra. One thing we noticed is even though Delhi’s reported cases is high but death is less. This could be because of easy access to hospitals and medicines as Delhi is the national capital. States like Maharashtra and Punjab have maximum death inspite of low reported cases.

To arrange the data on the map, we will use ggmap package.

require(ggmap)

We need to get the longitude and latitude of all the states that we want to pin and this we can do with ‘qmap(’india’, zoom = 5) and then use gglocator() function. Once gglocator is initiated, go ahead and click the map where you want to generate the longitude and latitude of that place.

long <- c(72.37489, 70.39125, 77.20461, 79.01575, 73.58232, 78.75702,
          80.56816, 75.99718, 74.78975)
latt <- c(26.61737, 21.7289, 28.30029, 17.24112, 18.12265, 8.826543, 
          25.57904, 33.91001,31.42571)

We will add these two variables in our dataframe and select only those states which has reported more than 100 cases and select only Reported cases, longitude and latitude variables.

h1n1.100 <- filter(h1n1, Reported.cases > 100)
h1n1.100 <- data.frame(h1n1.100, long, latt)
h1n1.100 <- select(h1n1.100, Reported.cases, long, latt)
h1n1.100
##   Reported.cases     long      latt
## 1           4318 72.37489 26.617370
## 2           2886 70.39125 21.728900
## 3           2060 77.20461 28.300290
## 4           1233 79.01575 17.241120
## 5            801 73.58232 18.122650
## 6            225 78.75702  8.826543
## 7            165 80.56816 25.579040
## 8            109 75.99718 33.910010
## 9            105 74.78975 31.425710

Now we map all the datapoints.

India <- qmap('india', zoom = 5, color = "bw")
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=india&zoom=5&size=%20640x640&scale=%202&maptype=terrain&sensor=false
## Google Maps API Terms of Service : http://developers.google.com/maps/terms
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=india&sensor=false
## Google Maps API Terms of Service : http://developers.google.com/maps/terms
reported.cases <- India + stat_density2d(aes(x = long, y = latt, fill = ..level..), size = 0.5, bins = 8, data = h1n1.100, geom = "polygon", alpha = 0.2)
reported.cases + scale_fill_continuous(low = "yellow", high = "red")

We will also do barplot to see how many deaths correspond to reported cases for each state. For this we need reshape package and ggplot2 package.

require(reshape)
require(ggplot2)
flu <- melt(h1n1, id = "State")

ggplot(data = flu, aes(x = State, y = value, fill = variable)) + 
  geom_bar(stat = "identity", position  = position_dodge()) +
  ylab("Count") + xlab("States") + ggtitle("Reported and Death cases of H1N1 till 22nd Feb 2015")