This function takes a year-list containing individual tibbles - one per month - that have been validated and collapses them into a single tibble.

cs_collapse(.data)

Arguments

.data

A list containing monthly crime data

Value

A tibble containing all crime data in a given year-list object.

Details

cs_collapse applies common sense variable classes to a number of variables. This is motivated by issues that originate with SLMPD .csv files. When they are imported, the readr package sometimes applies the incorrect variable classes because of formatting issues in the tables. Since the tables have inconsistent variable names and numbers of variables, all variables are imported as chr data. During cs_collapse's execution, the following changes are made:

Count

Converted to int

Crime

Converted to int

District

Converted to int

ILEADSAddress

Converted to int

Neighborhood

Converted to int

CADAddress

Converted to int

XCoord

Converted to dbl

YCoord

Converted to dbl

Examples

# load example year-list object load(system.file("testdata", "yearList17.rda", package = "compstatr", mustWork = TRUE)) # validate cs_validate(yearList17, year = 2017)
#> [1] FALSE
# standaridze May, which has 26 variables yearList17 <- cs_standardize(yearList17, month = "May", config = 26) # validate again to confirm fix cs_validate(yearList17, year = 2017)
#> [1] TRUE
# collapse now that the data are valid crimeReports17 <- cs_collapse(yearList17)