library(readxl)
ccrb = read_excel( "ccrbcomplaints.xlsx")

1. Number of Incidences Complaints over the years:

ggplot(ccrb,aes(x=ReceivedYr))+
  geom_bar(stat="count", fill="light blue", col = "light blue")+
  labs(title="Trends in Complaints from 2006-2016", x="Year in which complaint was received",y="Number of Complaints")+
  theme_bw()


As we have started reviewing incidences that were closed from 2006 onwards, 2004 and 2005 incidences that were recorded before 2016 onward, and hence will need to be excluded from our analysis.

2. Comolaints by allegation type:

pie3D(table(ccrb$AllegationFADOType), labels =  c("Abuse of Authority", "Discourtesy","Force", "N/A", "Offensive Language"), main="Complaints by Allegation Type" , explode = 0.1, labelcex = 0.8, theta=pi/6, col = c("maroon", "light blue", "pink", "dark blue", "light green"))


About 50% of the allegations pertained to abuse of authority. The other major causes for complaits were force and discourtesy.


5. Complaints by Allegation Type and Boroughs:

ggplot(ccrb,aes(x=BoroughofOccurrence, fill=AllegationFADOType)) + geom_histogram(stat = "count") + labs (title = "Complaints by Allegation Type and NYC Boroughs", x="Borough", y="Complaints") + theme (legend.position = "bottom") + scale_fill_discrete(name = "Allegation Type")


Maximum number of complaints were from Brooklyn, followed by Bronx and Manhattan respectively. The lowest number of compliants were from Staten Island, which is probably because of lesser resident population in the borough.


6. Average time taken to close an incident by Allegation Type:

ccrb$TimetoClose = ccrb$CloseYr-ccrb$IncidentYr

ggplot(ccrb, aes(x=BoroughofOccurrence, y = TimetoClose, fill = BoroughofOccurrence)) + geom_bar(stat="identity", position = "dodge" ) + labs (title = "Average time taken to close complaints by Boroughs", x="Borough", y="Avg time taken to close complaint") + stat_summary (aes(fun.y = 'mean')) + ylim(0, 1)


On an average, all the complaits are addressed within a year. The average time taken to close complaints is approximately the same in areas with higher volumes of complaints.

7. Proportion of Complaint file mode:

ggplot(ccrb, aes(x =AllegationFADOType)) + geom_bar (aes(fill = as.factor(IsFullInvestigation)), stat = "count", position = 'stack') 


A little less than 50% of the allegations were fully investigated. The distribution is similar across all allegation types.


8. Location of incidence:

ggplot(ccrb, aes(x =IncidentLocation)) + geom_histogram(stat = "count") + coord_flip() 


Majority of the incidences for which complaints were made took place on a highway or a street.

9. Encounter Outcomes by Allegation Type:

ggplot(ccrb, aes(x = AllegationFADOType, fill = EncounterOutcome)) + 
  geom_histogram(position = 'dodge', stat = 'count')


Proportionally, for allegations of abuse of authority, there were more instances where arrests or summons were not made. For force, on the other hand, there were a higher number of arrests or summons.


10. Encounter Outcomes by Boroughs:

ggplot(ccrb, aes(x = BoroughofOccurrence, fill = EncounterOutcome)) + 
  geom_histogram(position = 'dodge', stat = 'count')


In Brooklyn and Bronx, the areas with the higest volume of complaints, more arrests were made than the cases where no action was taken. In Manhattan, proportionally there were more instances where arrests or summons were not made.


Summary of findings:

There has been a significant decline in complaints across all boroughs and for all allegation types. This could either be because of mitigative action taken by the departments or because people have identified other modes of compalining or showing their displeasure. Majority of the complaints are made for abuse of authority and force. The NYC authorities might find it pertinent to identify causes for these complaints, and design avenues for improving public image. Brooklyn and Bronx have seen a significant decline proportionate to the other boroughs, but continue to see the highest volumes of complaints. Majority of the incidences are observed on the street/ highways or from apartments, but very little video evidence is available.