Giter Club home page Giter Club logo

spcrimr's Introduction

spcrimr: tidy data from Secretaria de Segurança Pública - São Paulo, Brazil

spcrimr is a simple package to download and use tidy data from Secretaria de Segurança Pública, state of Sao Paulo, Brazil.

spcrimr was inspired by this post in Curso-R blog. Thank you guys!

With this package you can easily download tables from SSP’s website.

The download_table_sp() function request tables from SSP’s website with R and displays it in the conlose.

Installation

You can install spcrimr from github with:

# install.packages("devtools")
devtools::install_github("rdurl0/spcrimr")

Example

Data

library(spcrimr)
library(tibble)

glimpse(ssp_ocorrencias_crimes)
#> Observations: 10,320
#> Variables: 22
#> $ nm_municip                                           <chr> "ADAMANTI...
#> $ municipio                                            <int> 1, 1, 1, ...
#> $ ano                                                  <dbl> 2002, 200...
#> $ furto_de_veiculo                                     <int> 0, 3, 2, ...
#> $ furto_outros                                         <int> 319, 277,...
#> $ homicidio_culposo_outros                             <int> 0, 0, 0, ...
#> $ homicidio_culposo_por_acidente_de_transito           <int> 3, 4, 2, ...
#> $ homicidio_doloso                                     <int> 1, 1, 4, ...
#> $ homicidio_doloso_por_acidente_de_transito            <int> 0, 0, 0, ...
#> $ latrocinio                                           <int> 1, 0, 0, ...
#> $ lesao_corporal_culposa_outras                        <int> 29, 21, 1...
#> $ lesao_corporal_culposa_por_acidente_de_transito      <int> 160, 168,...
#> $ lesao_corporal_dolosa                                <int> 322, 344,...
#> $ roubo_a_banco                                        <int> 0, 0, 0, ...
#> $ roubo_de_carga                                       <int> 0, 1, 0, ...
#> $ roubo_de_veiculo                                     <int> 0, 1, 1, ...
#> $ tentativa_de_homicidio                               <int> 5, 1, 3, ...
#> $ total_de_estupro                                     <int> 0, 0, 1, ...
#> $ total_de_roubo_outros                                <int> 4, 7, 5, ...
#> $ vitimas_em_homicidio_doloso                          <int> 1, 1, 4, ...
#> $ vitimas_em_homicidio_doloso_por_acidente_de_transito <int> 0, 0, 0, ...
#> $ vitimas_em_latrocinio                                <int> 1, 0, 0, ...

glimpse(ssp_produtividade_policial)
#> Observations: 10,320
#> Variables: 16
#> $ nm_municip                                 <chr> "ADAMANTINA", "ADAM...
#> $ municipio                                  <int> 1, 1, 1, 1, 1, 1, 1...
#> $ ano                                        <dbl> 2002, 2003, 2004, 2...
#> $ armas_de_fogo_apreendidas                  <int> 20, 23, 16, 12, 18,...
#> $ flagrantes_lavrados                        <int> 54, 58, 49, 36, 43,...
#> $ infratores_apreendidos_em_flagrante        <int> 8, 9, 4, 3, 6, 7, 3...
#> $ infratores_apreendidos_por_mandado         <int> 0, 0, 1, 0, 0, 1, 0...
#> $ ocorrências_de_apreensao_de_entorpecentes1 <int> 11, 9, 1, 7, 15, 6,...
#> $ ocorrências_de_porte_de_entorpecentes      <int> 22, 28, 25, 29, 40,...
#> $ ocorrências_de_porte_ilegal_de_arma        <int> 8, 7, 7, 4, 2, 2, 2...
#> $ ocorrências_de_tráfico_de_entorpecentes    <int> 12, 12, 9, 12, 20, ...
#> $ pessoas_presas_em_flagrante                <int> 66, 78, 60, 46, 58,...
#> $ pessoas_presas_por_mandado                 <int> 18, 25, 10, 68, 107...
#> $ prisões_efetuadas                          <int> 54, 58, 49, 36, 43,...
#> $ tot_de_inquéritos_policiais_instaurados    <int> 366, 332, 273, 290,...
#> $ veiculos_recuperados                       <int> 0, 3, 1, 0, 6, 4, 2...

glimpse(ssp_variables_names)
#> Observations: 32
#> Variables: 3
#> $ variaveis_tidy <chr> "armas_de_fogo_apreendidas", "flagrantes_lavrad...
#> $ variaveis_raw  <chr> "Nº DE ARMAS DE FOGO APREENDIDAS", "Nº DE FLAGR...
#> $ dataset        <chr> "produtividade_policial", "produtividade_polici...

glimpse(seade) # a database from SEADE
#> Observations: 40
#> Variables: 2
#> $ ano  <int> 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 198...
#> $ data <list> [<tbl_df[645 x 92]>, <tbl_df[645 x 92]>, <tbl_df[645 x 9...

Functions

The download_table_sp function download tables from SSP’s website

download_table_sp(ano = 2019,
                  municipio = 500,
                  type = "ctl00$conteudo$btnMensal") %>% glimpse()
#> Observations: 23
#> Variables: 16
#> $ Natureza  <chr> "HOMICÍDIO DOLOSO (2)", "Nº DE VÍTIMAS EM HOMICÍDIO ...
#> $ Jan       <int> 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 0, 1, 1, 1...
#> $ Fev       <int> 1, 1, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 2, 1...
#> $ Mar       <int> 1, 1, 0, 0, 1, 0, 0, 0, 7, 1, 0, 0, 0, 0, 0, 0, 5, 5...
#> $ Abr       <int> 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2...
#> $ Mai       <chr> "...", "...", "...", "...", "...", "...", "...", ".....
#> $ Jun       <chr> "...", "...", "...", "...", "...", "...", "...", ".....
#> $ Jul       <chr> "...", "...", "...", "...", "...", "...", "...", ".....
#> $ Ago       <chr> "...", "...", "...", "...", "...", "...", "...", ".....
#> $ Set       <chr> "...", "...", "...", "...", "...", "...", "...", ".....
#> $ Out       <chr> "...", "...", "...", "...", "...", "...", "...", ".....
#> $ Nov       <chr> "...", "...", "...", "...", "...", "...", "...", ".....
#> $ Dez       <chr> "...", "...", "...", "...", "...", "...", "...", ".....
#> $ Total     <int> 2, 2, 0, 0, 1, 0, 0, 0, 18, 2, 0, 0, 0, 1, 0, 1, 10,...
#> $ municipio <dbl> 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 50...
#> $ ano       <dbl> 2019, 2019, 2019, 2019, 2019, 2019, 2019, 2019, 2019...
insert_munic_idx("any vector") %>% glimpse()
#> List of 1
#>  $ : int [1:645] 1 2 3 4 5 6 7 8 9 10 ...

Citation

To cite spcrimr, write citation("spcrimr"):

To cite package ‘spcrimr’ in publications use:

  Raul de Sá Durlo (2019). spcrimr: tidy data from SSP-SP.
  R package version 0.0.9000.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {spcrimr: tidy data from SSP-SP},
    author = {Raul de Sá Durlo},
    year = {2019},
    note = {R package version 0.0.9000},
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.