R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

x <- read_csv("https://raw.githubusercontent.com/Financial-Times/police-misconduct-complaints-analysis/main/output/philly_clean.csv") %>% 
  select(officer_id, po_race, po_sex)
## 
## -- Column specification --------------------------------------------------------
## cols(
##   complaint_id = col_character(),
##   date_received = col_date(format = ""),
##   district_occurrence = col_character(),
##   general_cap_classification = col_character(),
##   summary = col_character(),
##   officer_id = col_double(),
##   po_race = col_character(),
##   po_sex = col_character(),
##   po_assigned_unit = col_character(),
##   allegations_investigated = col_character(),
##   investigative_findings = col_character(),
##   disciplinary_findings = col_character()
## )
x %>% 
  group_by(officer_id) %>%  
  summarize(total = n()) %>% 
  arrange(desc(total)) %>% 
  mutate(officer_id = as.character(officer_id)) %>% 
  slice(1:10) %>% 

ggplot(mapping = aes(x = officer_id, y = total)) + 
  geom_col()+
  labs(title = "Police Complaints by ID", subtitle = "Officers are under fire, send help.", x = "Officer ID", y = "Count")

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.