项目作者: evanodell

项目描述 :
Download Data on UK Police and Crime
高级语言: R
项目地址: git://github.com/evanodell/ukpolice.git
创建时间: 2019-03-31T10:37:27Z
项目社区:https://github.com/evanodell/ukpolice

开源协议:Other

下载


ukpolice

License:
MIT
Travis build
status
AppVeyor build
status
Coverage
status
CRAN\_Status\_Badge
GitHub
tag

DOI
R build
status

The ukpolice package downloads data from the UK Police public data
API, the full docs of which are available at
https://data.police.uk/docs. Data is available on police forces,
crimes, policing areas and stop-and-search.

ukpolice is on CRAN, which you can download using:

  1. install.packages("ukpolice")

You can install the development version of ukpolice from github with:

  1. # install.packages("devtools")
  2. devtools::install_github("evanodell/ukpolice")

Data is available on police forces, crimes, policing areas and
stop-and-search. All functions begin with ukc_.

The example below queries stop and searches by the Thames Valley Police
in December 2018, and plots them by police-reported ethnic group.

  1. library(ukpolice)
  2. library(ggplot2)
  3. library(dplyr)
  4. tv_ss <- ukc_stop_search_force("thames-valley", date = "2020-07")
  5. tv_ss2 <- tv_ss %>%
  6. filter(!is.na(officer_defined_ethnicity) & outcome != "" ) %>%
  7. group_by(officer_defined_ethnicity, outcome) %>%
  8. summarise(n = n()) %>%
  9. mutate(perc = n/sum(n))
  10. theme_set(theme_bw())
  11. p1 <- ggplot(tv_ss2, aes(x = outcome, y = perc,
  12. group = outcome, fill = outcome)) +
  13. geom_col(position = "dodge") +
  14. scale_y_continuous(labels = scales::percent,
  15. breaks = seq(0.25, 0.8, by = 0.25)) +
  16. scale_x_discrete(labels = scales::wrap_format(20)) +
  17. theme(legend.position = "none",
  18. axis.text.x = element_text(size = 7, angle = 45, hjust = 1)) +
  19. labs(x = "Outcome",
  20. y = "Percentage of stop and searches resulting in outcome",
  21. title = "Stop and Search Outcomes by Police-Reported Ethnicity",
  22. subtitle = "Thames Valley Police Department, July 2020",
  23. caption = "(c) Evan Odell | CC-BY-SA") +
  24. facet_wrap(~officer_defined_ethnicity)
  25. p1

For more details, see the package vignette
vignette
and function
documentation
.

Meta

Please note that the ‘ukpolice’ project is released with a Contributor
Code of
Conduct
.
By contributing to this project, you agree to abide by its terms.

The UK Police API is operated by the UK Government’s Home Office. The
ukpolice package is not affiliated with the Home Office. All data
accessed through ukpolice is licenced with Open Government Licence
v3.0
.

Get citation information for ukpolice in R with
citation(package = 'ukpolice'), or use the citation information below:

Odell E, Tierney N (2020). ukpolice: Download Data on UK Police and
Crime
. doi:
10.5281/zenodo.2619537, R
package version 0.2.2, URL: https://github.com/evanodell/ukpolice.

A BibTeX entry for LaTeX users is:

  1. @Manual{,
  2. title = {{ukpolice}: Download Data on UK Police and Crime},
  3. author = {Evan Odell and Nicholas Tierney},
  4. year = {2020},
  5. note = {R package version 0.2.2},
  6. doi = {10.5281/zenodo.2619537},
  7. url = {https://github.com/evanodell/ukpolice},
  8. }