summarize_arrest: Summarize arrest data

Description Usage Arguments Details Examples

View source: R/arrest.R

Description

summarize_arrest() is a function that queries arrest information from FBI Crime API and returns a data frame. You can choose whether to summarize by offense type or not with by_offense_type and input the offense(s) with offense. You can also specify aggregation level (national, agencies, regions, or states), aggregation variable (age, ethnicity, etc.), and time span in this function.

Usage

1
2
3
4
5
6
7
8
9
summarize_arrest(
  by_offense_type = FALSE,
  offense = NULL,
  level = "national",
  level_detail = NULL,
  variable,
  since,
  until
)

Arguments

by_offense_type

a boolean. TRUE means to summarize by offense type, FALSE means to return information about all offense types. If omitted, FALSE is assumed.

offense

a string or a list, the offense type(s) to request. If omitted, NULL is assumed.

level

a string, the level of aggregation. It can be national, agencies, regions, or states. If omitted, national is assumed.

level_detail

a string or a list. Use this parameter to indicate what are the agencies/regions/states you want to query. For example, when level = 'agencies', then specify the ORI code of the agencies here. If level = 'regions' , then specify what regions to include here. There are four region categories available for choosing: Northeast, Midwest, West, and South. If level = 'states', then specify state abbreviations here, e.g. c('AL', 'AZ'). Note, when level = 'national', this parameter should be NULL.

variable

a string, the rule for aggregating. The availale arguments for this parameter vary for different endpoints of the API. Please check the API document (https://crime-data-explorer.fr.cloud.gov/api) for details. Required.

since

a number, the year to start

until

a number, the year to end

Details

Before calling any querying functions, you should pass your API KEY with set_fbi_crime_api_key().

Examples

1
2
3
4
summarize_arrest(by_offense_type = TRUE, offense = c('aggravated-assault','rape'), level = 'states', level_detail = c('NY','MA'), variable = 'race', since = 2010, until = 2011)
summarize_arrest(by_offense_type = TRUE, offense = c('aggravated-assault','rape'), variable = 'race', since = 2010, until = 2011)
summarize_arrest(by_offense_type = FALSE, level = 'regions', level_detail = c('South','Midwest'), variable = 'all', since = 2015, until = 2016)
summarize_arrest(by_offense_type = FALSE, variable = 'all', since = 2015, until = 2016)

SUN-Wenjun/fbicrime documentation built on Dec. 25, 2019, 5:12 a.m.