Chapter 21 Type of Crime Analysis
We examine the various types of Crime and plot the Top 20 Crimes in the bar plot.
LACrime %>%
group_by(CrimeCodeDescription) %>%
tally() %>%
arrange(desc(n)) %>%
head(20) %>%
mutate(CrimeCodeDescription = reorder(CrimeCodeDescription,n)) %>%
ggplot(aes(x = CrimeCodeDescription,y = n)) +
geom_bar(stat='identity',colour="white", fill =fillColor2) +
geom_text(aes(x = CrimeCodeDescription, y = 1, label = paste0("(",n,")",sep="")),
hjust=0, vjust=.5, size = 4, colour = 'black',
fontface = 'bold') +
labs(x = 'CrimeCodeDescription', y = 'Count of Incidents',
title = 'Count of Incidents and CrimeCodeDescription') +
coord_flip() +
theme_bw()
Battery - Simple Assault , Burglary from Vehicle , Vehicle -Stolen , Burglary and Theft -Plain Petty are among the most common crimes.