Skip to content

Instantly share code, notes, and snippets.

@alexsoble
Last active June 30, 2016 21:50
Show Gist options
  • Save alexsoble/932321f8443675a53166919eb7ebbec8 to your computer and use it in GitHub Desktop.
Save alexsoble/932321f8443675a53166919eb7ebbec8 to your computer and use it in GitHub Desktop.

DATA

https://github.com/invinst/shootings-data/blob/master/Clean/May2016/dat_may2016.csv

R

[1] Concatenate first name + last name:

concat_names <- paste(data$Accused_FName, data$Accused_LName)
data$concat_names=concat_names

[2] Make a slice of the data with just concatenated names plus complaint number:

data_subset <- subset(data, select = c(Complaint_Number, concat_names))

[3] Drop rows with missing accused officer names:

subset_both <- subset(data_subset, concat_names != " ")

[4] Find unique rows by complaint number + accused officer name:

uniq_data = unique(subset_both)

[5] Print summary table:

table(uniq_data$concat_names)

Output

ANDREW NAPOLITANO: 1 
ANTHONY ROSEN: 1 
CATHERINE DOUBEK: 1 
CHARLES MEADOWS SR: 1 
DANIEL CASTILLO: 1 
DANIEL GOON: 1 
DANIEL LOPEZ: 1 
DANIEL SMITH: 1 
DANIEL VAZQUEZ: 1 
DARRYL EDWARDS: 1 
GEORGE HERNANDEZ: 1 
HARRY MATHEOS: 1 
JAIME GAETA: 1 
JASON VAN DYKE: 1 
JEFFERY JONES JR: 1 
JORGE MENDEZ JR: 1 
KEVIN FRY: 1 
LEONARD JARVIS: 1 
LOUIS GARCIA: 1 
MANUEL GONZALEZ JR.: 1 
MARCO LEON: 1 
MICHAEL CURRY: 1 
MICHAEL QUALLS: 1 
NILLION RANKIN: 1 
NORMAN KWONG: 1 
RAPHAEL MITCHEM: 1 
ROBERT ONTIVEROS: 1 
ROTHIEL DAVIS: 1 
TERRENCE PRATSCHER: 1 
VIOLET REY: 1 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment