The data for this map is taken from wikipedia statewise sex ratio page (https://en.wikipedia.org/wiki/List_of_states_and_union_territories_of_India_by_population). Sex ratio is defined as the number of females per 1000 males.

Storing Data

Since there is no tabulated data available online, the data is input as a vector. Similarly, the latitudes and longitudes of the States of India are stored manually.

The data is stored into the following variables: name, sex_ratio, longitude, latitude.

Disecting the data

Here, the data is divided into two parts, the best performing 7 states and the worst performing 7 states in terms of sex ratio.

topindices = match(x = tail(sort(sex_ratio), 7), sex_ratio)
bottomindices = match(head(sort(sex_ratio), 7), sex_ratio)

Plotting Map

The map below shows the best performing seven states in Blue and the worst performing 7 states in Red.

library(leaflet)
df = as.data.frame(cbind(longitude, latitude))
df = df[c(topindices, bottomindices),]

leaflet() %>%
  addTiles() %>%
  addCircleMarkers(lat = df[1:7, 2], lng = df[1:7, 1], popup = name[topindices], radius = 6, fillOpacity = 1, stroke = FALSE) %>%
  addCircleMarkers(lat = df[8:14, 2], lng = df[8:14, 1], popup = name[bottomindices], color = "red", radius= 4, fillOpacity = 1)