I am working with R in RStudio and would like to plot via highchart package a graphic that includes on the x-Axis the crime type, and on the y-Axis the arrest rate in %. So to see on which crime type the highest arrest was made. I am working with following code in shiny, which is working but not ploting what exactly I want:
output$top20arrestCrime <- renderHighchart({
arrestCrimeAnalysis <- cc %>%
group_by(Primary.Type, Arrest == TRUE) %>%
summarise(Total = n()) %>%
arrange(desc(Total))
hchart(arrestCrimeAnalysis, "column", hcaes(x = Primary.Type, y = Total, color = Total)) %>%
hc_exporting(enabled = TRUE, filename = "Top_20_Locations") %>%
hc_title(text = "Top 20 Crime Types") %>%
hc_subtitle(text = "(2001 - 2016)") %>%
hc_xAxis(title = list(text = "Crime Type"), labels = list(rotation = -90)) %>%
hc_yAxis(title = list(text = "Arrest Rate %")) %>%
hc_colorAxis(stops = color_stops(n = 10, colors = c("#d98880", "#85c1e9", "#82e0aa"))) %>%
hc_add_theme(hc_theme_smpl()) %>%
hc_legend(enabled = FALSE)
})
I am working with this dataset: https://www.kaggle.com/currie32/crimes-in-chicago.
when I run the code, it just show me on the x-Axis the crime type (e.g. THEFT, ROBERRY) etc, which is correct and on the y-Axis the sum of thefts for example from 2001-2016. But I want on the y-Axis the Arrest Rate in percentage, so how many arrests happened. and this in a highcharter with the top 20 arrests crime types.
Example screenshot of Shiny app