-
Notifications
You must be signed in to change notification settings - Fork 1
/
spay_neuter.Rmd
42 lines (35 loc) · 2.03 KB
/
spay_neuter.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
title: "Dog Bites by Gender and Spayed/Neutered Status"
---
```{r, echo = FALSE, message = FALSE, results = 'hide', warning = FALSE}
library(tidyverse)
library(ggthemes)
library(plotly)
# read data
dog_bite <- read_csv("./data/dog_bite_12.4.csv")
# figure
bite_figure <- dog_bite %>%
group_by(gender, spay_neuter, pit_bull) %>%
count() %>% # counts of spay/neuter status by sex and breed type
ungroup() %>%
mutate(gender = recode(gender, 'F' = 'Female', 'M' = 'Male', 'U' = 'Unknown'), # recode gender variable
spay_neuter = ifelse(spay_neuter == TRUE, "Yes", "No"),
pit_bull = ifelse(pit_bull == TRUE, "Pit Bull", "Other")) %>% # recode spay/neuter status
ggplot(aes(x = spay_neuter, y = n, fill = pit_bull)) +
geom_bar(stat = "identity", position = "stack") +
labs(y = "Number of Bites",
x = "Spayed/Neutered Status") +
theme_hc() +
facet_grid(~ gender) +
viridis::scale_fill_viridis(
name = 'Dog Breed',
discrete = T
)
```
```{r, echo = FALSE, fig.width=9}
# render as plotly
ggplotly(bite_figure)
```
Male dogs appear to bite more often than their female counterparts - more than twice as much. Among dogs whose gender is known, non-spayed/neutered dogs bite slightly less than their fixed counterparts. Interestingly, this relationship is flipped for pit bulls. Unfixed pit bulls bite more than fixed pit bulls regardless of gender, and this effect is much more pronounced in males than females.
We wonder if there may be misclassification error associated with the spaying status of female dogs since it is easier to physically see whether or not a male dog is neutered. The "eye test" of spaying status for female dogs is not quite as easy to do.
With that said, it is especially worth noting that we have a handful of dogs whose gender is unknown, which brings up the integrity of their spayed/neutered status since it seems almost all dogs of unknown gender were coded to be not spayed/neutered. It may be that the truth underlying this data coding would result in a diffierent conclusion.