Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NA #10

Closed
xnoorrr opened this issue Apr 12, 2018 · 6 comments
Closed

NA #10

xnoorrr opened this issue Apr 12, 2018 · 6 comments

Comments

@xnoorrr
Copy link

xnoorrr commented Apr 12, 2018

when using this script for example for the data of Florida, i only get NA at n_searches and n_hits

@janovergoor
Copy link
Collaborator

what script are you referring to?

@xnoorrr
Copy link
Author

xnoorrr commented Apr 13, 2018

i'm sorry. I was trying to work out this part:

summary_stats <- function(search_conducted, contraband_found) {
n_stops = length(search_conducted)
n_searches = sum(search_conducted)
n_hits = sum(contraband_found)
search_rate = n_searches / n_stops
hit_rate = n_hits / n_searches
return(data.frame(n_stops, n_searches, n_hits, search_rate, hit_rate))
}

basic_summary_statistics_by_race = florida %>%
group_by(driver_race) %>%
do(summary_stats(.$search_conducted, .$contraband_found))
basic_summary_statistics_by_race

@xnoorrr
Copy link
Author

xnoorrr commented Apr 13, 2018

A tibble: 6 x 6

Groups: driver_race [6]

driver_race n_stops n_searches n_hits search_rate hit_rate

1 "" 1345 NA NA NA NA
2 Asian 69112 NA NA NA NA
3 Black 1021743 NA NA NA NA
4 Hispanic 1173182 NA NA NA NA
5 Other 138772 NA NA NA NA
6 White 3017292 NA NA NA NA

@epierson9
Copy link
Collaborator

I assume this is the result of running on FL data? If so, this is happening because the FL data has NAs in the search_conducted/contraband_found columns (because some stops lack that data), so the search and hit counts/rates become NA as well. You probably want to filter those out prior to computing search and hit statistics; this is not necessary for CT, the state used in the tutorial. (Actually, FL has no contraband found data at all, so hit rates will not be computable).

@xnoorrr
Copy link
Author

xnoorrr commented Apr 14, 2018

Ah I was expecting that but assumed I made a mistake with the data because i couldn't imagine there wasn't found any contraband at all. Too bad, i'm going to try some thing else. thanks for your help!

@epierson9
Copy link
Collaborator

Good luck! In case you haven't yet seen it, the data readme will often provide useful tips on specific states (eg, missing data). https://github.com/5harad/openpolicing/blob/master/DATA-README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants