3 minute read

Brazil, where I live, has a shockingly high murder rate. I mean, it’s freaking astounding. A recent blog I read (see it here) caused a bit of discussion among some friends of mine on facebook. Is Brazil a failed state? The obvious answer seems ‘no’, but then again, isn’t security one of the basic functions of the state? Just how bad is it with regard to murders in Brazil? (Pretty nuts is the answer.)

We can visualize this is in R to get some idea of how nuts it is. There’s a table on Wikipedia that we can scrape:


countrycode_data <- select(countrycode_data, region = country.name.en, iso3c)

page <- read_html("https://en.wikipedia.org/wiki/List_of_countries_by_intentional_homicide_rate") %>% 
  html_nodes(css = "#mw-content-text > div > table:nth-child(28)") %>% 
  html_table(fill = T) %>% 
  .[[1]] %>% 
  select(1:3) %>% 
  magrittr::set_colnames(c("region", "rate", "count")) %>% 
  slice(224:441) %>% 
  mutate(rate = as.numeric(rate),
         count = as.numeric(gsub(",", "", count)),
         region = ifelse(region == "United States", "United States of America", region))

tb <- left_join(page, countrycode_data) %>% 

Let’s visualize this on a map of the world (the missing countries we have no data for):


map_world <- map_data(map = "world") %>% 
  mutate(region = tolower(region))

tb <- tb %>% 
  mutate(region = ifelse(region == "United States of America", "USA", region))

tb <- left_join(tb, map_world) %>% 

ggplot() + 
  theme_minimal() +
  geom_map(data = tb, map = tb, aes(map_id = region, 
                                    x = long, y = lat, 
                                    fill = rate)) +
  scale_fill_gradient(high = "#990000", low = "#E9CACA") 

Here we’re graphing the rate, which doesn’t quite let us grasp the enormity of the murders in Brazil. Per capita, Honduras is infamous. Let’s plot the counts:

ggplot() + 
  theme_minimal() +
  theme(legend.position = "right") +
  geom_map(data = tb, map = tb, aes(map_id = region, 
                                    x = long, y = lat, 
                                    fill = count)) +
  scale_fill_gradient(high = "#990000", low = "#E9CACA") 

Now we start to get an idea of just how many people are killed in Brazil. In fact, if we take out the 26 most violent states apart from Brazil, then Brazil has more homicides than all of the countries in blue (keeping in mind there are missing data):

'%ni%' <- Negate('%in%')
others <- c("India", "Mexico", "South Africa","Nigeria", "Pakistan", 
            "Colombia", "USA", "China", "Philippines", "Myanmar", 
            "Ethiopia", "Honduras", "Guatemala", "Bangladesh", 
            "Uganda", "El Salvador", "Argentina", "Turkey", "Egypt",
            "Kenya", "Thailand", "Iraq", "Sudan", "Angola",  "Peru", 
others <- tolower(others)
tb <- tb %>% 
  mutate(Murders = ifelse(region == "brazil", "kill-ville", ifelse(
    region %in% others, "other violent states", "peaceful")))

ggplot() + 
  theme_minimal() +
  theme(axis.title = element_blank(),
        axis.text = element_blank()) +
  geom_map(data = tb, map = tb, aes(map_id = region, 
                                    x = long, y = lat, 
                                    fill = Murders)) +
  scale_fill_manual(values = c("#990000", "gray", "cornflowerblue")) 

Crazy. By the way, I love lots of things about Brazil: the people, the food… they know how to throw a party and the place can be jaw-droppingly beautiful. This violence has also never touched me personally – I live in a nice neighbourhood in São Paulo and so these statistics are insane to me. But obviously in places like Rio and the Northeast, (and lately, Espirito Santo – 144 people killed in eight days when the police went on strike) homicide has just reached horrific levels. Sadly, you can guess easily what section of society bears the brunt of these crimes.

(I saw a very similar plot in the last two weeks, but after searching the net, I couldn’t find it. So I made it again. :smile:)

comments powered by Disqus