Description Usage Arguments Details Value Examples
The SLMPD data contains 5 or 6 digit codes to refer to
specific categories of crime. cs_crime_cat
transforms these
into either string, factor, or simplified numeric categories
like "murder" or "aggravated assault". This can be used
on any police department's data where codes like 31111
(robbery with a firearm)
or 142320
(malicious destruction of property) are used to identify crimes.
1 | cs_crime_cat(.data, var, newVar, output)
|
.data |
A tibble or data frame |
var |
Name of variable with 5 or 6 digit crime codes |
newVar |
Name of output variable to be created with simplified categories |
output |
Type of output - either |
The categories used here are derived from the U.S. Federal Bureau of Investigation's Uniform Crime Reporting codes.
A copy of the object with the new output variable appended to it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # load example data
testData <- january2018
# apply categories
testData <- cs_crime_cat(testData,var = crime, newVar = crimeCat, output = "numeric")
# preview categories
table(testData$crimeCat)
# apply categories
testData <- cs_crime_cat(testData,var = crime, newVar = crimeCat, output = "factor")
# preview categories
table(testData$crimeCat)
# apply categories
testData <- cs_crime_cat(testData,var = crime, newVar = crimeCat, output = "string")
# preview categories
table(testData$crimeCat)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.