Learn R Programming

ispdata

Sobre o pacote

O pacote ispdata permite acessar os dados do Instituto de Segurança Pública (ISP) do Rio de Janeiro por meio do R.

Instalação

Para instalar via CRAN:

install.packages("ispdata")
library(ispdata)

Para instalar a versão em desenvolvimento(GitHub):

install.packages("devtools")
devtools::install_github("igorlaltuf/ispdata")
library(ispdata)

Exemplos

Acessar estatísticas de segurança pública por área de delegacia de polícia:

df <- monthly_stats(by = 'cisp') 

Carregar o dicionário de dados da tabela acima:

data_dictionary <- monthly_stats_dictionary(by = 'cisp')

Acessar dados sobre feminicídio:

df <- crimes_against_life(type = "femicide")

Ver estatísticas sobre apreensão de armas:

df <- gun_seizure(gun_type = "firearms")

Carregar estatísticas de segurança pública em área de UPPs:

df <- upp_data(data = "stats")

Dados espaciais vetoriais dos limites das UPPs:

shape <- spatial_upp

Exemplo: Taxa de homicídios por intervenção policial em 2020 na cidade do Rio de Janeiro. Dados por Área Integrada de Segurança Pública (AISP).


library(ispdata)
library(dplyr)
library(ggplot2)
library(sf)

pop <- population(data = 'cisp_yearly')

df <- monthly_stats(by = 'cisp') |> 
  left_join(spatial_cisp, by = c("cisp" = "dp", "aisp")) |>
  filter(aisp %in% c(27, 40, 31, 14, 18, 41, 9, 6, 23, 3, 16, 22, 4, 17, 19, 2),
         ano == '2020') |>
  group_by(ano, cisp, geometry) |>
  summarise(hom_por_interv_policial = sum(hom_por_interv_policial)) |>
  left_join(pop, by = c("cisp" = "circ", "ano")) |>
  mutate(v_100k_hab = hom_por_interv_policial/pop * 100000) |>
  st_as_sf() 


ggplot() + 
  geom_sf(data = df, mapping = aes(fill = v_100k_hab), color = NA) +
  theme_classic() +
  scale_fill_viridis_c(name = "Quantidade para\ncada 100 mil hab") + 
  labs(title = "",
       subtitle = "") +
  coord_sf() +
  ggspatial::annotation_scale() +
  ggspatial::annotation_north_arrow(location = "br")

Citação

Para citar em trabalhos, use:

citation('ispdata')
#> 
#> To cite package 'ispdata' in publications use:
#> 
#> 
#> A BibTeX entry for LaTeX users is
#> 
#>   @Misc{,
#>     title = {ISPDATA: the package to access public security data from the State of Rio de Janeiro.},
#>     author = {Igor Laltuf},
#>     year = {2023},
#>     url = {https://github.com/igorlaltuf/ispdata},
#>   }

Copy Link

Version

Install

install.packages('ispdata')

Monthly Downloads

191

Version

1.1.2

License

MIT + file LICENSE

Maintainer

Igor Laltuf

Last Published

May 24th, 2023

Functions in ispdata (1.1.2)

upp_data

Access data from Pacifying Police Units (UPPs)
spatial_info

Access the information about spatial data
monthly_stats

Access the public security statistics of the State of Rio de Janeiro by month
spatial_regions_rj

Spatial Data from Regions of the State of Rio de Janeiro
monthly_stats_dictionary

Access the dictionaries of public security statistics of the State of Rio de Janeiro by month
population

Access population data
yearly_stats

Access the public security statistics of the State of Rio de Janeiro by year
spatial_risp

Spatial Data from Integrated Public Safety Regions (RISP)
spatial_upp

Spatial data of Pacifying Police Units (UPP) - 2017 Limits
bicycle_theft

Access the statistics about bicycle theft of the State of Rio de Janeiro
gun_seizure

Access data from gun seizure in State of Rio de Janeiro
gun_seizure_historical

Access historical data from seizure of firearms in State of Rio de Janeiro
crimes_against_life

Access the public security statistics about crimes against life in the State of Rio de Janeiro
spatial_aisp

Spatial Data from Integrated Public Safety Area (AISP)
car_fleet

Access data from car fleet
yearly_stats_dictionary

Access the dictionaries of public security statistics of the State of Rio de Janeiro by year
spatial_cisp

Spatial Data from Integrated Public Safety Circumscriptions (CISP)