fn_prepare_input_crime: Prepare input crime for GP-SMART

View source: R/fn_prepare_input_crime.R

fn_prepare_input_crimeR Documentation

Prepare input crime for GP-SMART

Description

Checks that the minimum necessary variables are present and calculates additional attributes needed for fn_gpsmart().

Usage

fn_prepare_input_crime(input_crime_raw)

Arguments

input_crime_raw

A data frame with 1 row and 9 columns:

case_id

A unique reference number for the input crime. Can be a character or numeric vector. Used to name gp-smart outputs.

offence_type

The type of input crime. A factor with levels "burglary", "robbery" or "sex", being the crimes GP-SMART is calibrated for use with.

x

Easting coordinate. Must be in metres to enable distance calculations.

y

Northing coordinate. Must be in metres to enable distance calculations.

start_date

Start date of the crime. A date in format "YYYY-MM-DD".

end_date

End date of the crime, if the exact date is not known. A date in format "YYYY-MM-DD".

start_time

Start time of the crime. A difftime in format "HH:MM:SS".

end_time

End time of the crime, if the exact time is not known. A difftime in format "HH:MM:SS".

location_type

The type of location in which the crime was committed. A factor with levels "residential", "commercial", "public", "street" or "unknown".

Details

  • The function will return an error if the input does not contain the correct columns in the correct format.

  • Season variables are based on Southern Hemisphere.

Value

A data frame the same as the input with 7 additional columns:

  • offence_subtype_icThe subtype of input crime, abbreviated (resburg, nonresburg, comrob, persrob, sex).

  • daypart_icThe day part of the input crime (daytime, evening, night).

  • weekpart_icThe week part of the input crime (Weekday, weekend).

  • spring_icWhether the input crime occurred in spring (1 = yes, 0 = no).

  • summer_icWhether the input crime occurred in summer (1 = yes, 0 = no).

  • autumn_icWhether the input crime occurred in autumn (1 = yes, 0 = no).

  • winter_icWhether the input crime occurred in winter (1 = yes, 0 = no).

Author(s)

Sophie Curtis-Ham

See Also

  • fn_prepare_suspect_data() checks that the minimum necessary variables are present and creates the input_suspects data frame for use in fn_gpsmart().

  • fn_gpsmart() filters and ranks input_suspects based on their probability of committing the input_crime.

Examples

data(example_input_crime_raw)
fn_prepare_input_crime(example_input_crime_raw)


Sophie-c-h/gpsmartr documentation built on April 13, 2022, 5:51 p.m.