cs_collapse: Collapse Months in Year List Object into Single Tibble

Description Usage Arguments Details Value Examples

View source: R/collapse.R

Description

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

Usage

1
cs_collapse(.data)

Arguments

.data

A list containing monthly crime data

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

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# load example year-list object
load(system.file("testdata", "yearList17.rda", package = "compstatr", mustWork = TRUE))

# validate
cs_validate(yearList17, year = 2017)

# standaridze May, which has 26 variables
yearList17 <- cs_standardize(yearList17, month = "May", config = 26)

# validate again to confirm fix
cs_validate(yearList17, year = 2017)

# collapse now that the data are valid
crimeReports17 <- cs_collapse(yearList17)

compstatr documentation built on July 8, 2020, 7:34 p.m.