count_offense: Count NIBRS offense data

Description Usage Arguments Details Examples

View source: R/offense.R

Description

count_offense() is a function that queries the count of different types of offense from FBI Crime API and returns a data frame based on the query result. You can specify offense type, level of aggregation (national, agencies, regions, or states), and selected levels (i.e. what are the states/regions/agencies you want to include) in this function.

Usage

1
count_offense(offense, level = "national", level_detail = NULL)

Arguments

offense

a string or a list, the offense type(s) to request. Required.

level

a string, the level of aggregation for counting. 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.

Details

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

Examples

1
2
3
4
count_offense(offense = 'burglary')
count_offense(offense = 'larceny', level = 'agencies', level_detail = 'MA0010100')
count_offense(offense = c('burglary','larceny'), level = 'regions', level_detail = c('South','Northeast'))
count_offense(offense = 'homicide', level = 'states', level_detail = c('AL', 'AZ'))

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