library(dplyr)
library(ggplot2)
# Calculate number of murders by borough
london_murders_counts <- london_murders %>%
group_by(borough) %>%
add_tally()
london_murders_counts
if (FALSE) {
# Add number of murders to geographic boundary data
london_boroughs_murders <- inner_join(london_boroughs, london_murders_counts, by = "borough")
# Map murders
ggplot(london_boroughs_murders) +
geom_polygon(aes(x = x, y = y, group = borough, fill = n), colour = "white") +
scale_fill_distiller(direction = 1) +
labs(x = "Easting", y = "Northing", fill = "Number of murders")
}
Run the code above in your browser using DataLab