##      ggplot2        dplyr    lubridate     reshape2     magrittr 
##         TRUE         TRUE         TRUE         TRUE         TRUE 
##      stringi RColorBrewer        tidyr     ggthemes       scales 
##         TRUE         TRUE         TRUE         TRUE         TRUE 
##     RSocrata    gridExtra    extrafont 
##         TRUE         TRUE         TRUE

Austin Animal Center FY15 Outcomes Updated Hourly

Uses the City of Austin’s data service http://data.austintexas.gov to pull Austin Animal Center’s “outcomes” of all cats and dogs leaving the city shelter (link)

Load data from site

# Austin Animal Center FY15 Outcomes *Updated Hourly*
Animal.Outcomes <- RSocrata::read.socrata("https://data.austintexas.gov/resource/fb53-k8de.csv")

Outcomes <- Animal.Outcomes
Outcomes$Breed = gsub(" Mix", "", Outcomes$Breed)
Outcomes <- separate(Outcomes, col = Breed, into = c("Breed.Primary", "Breed.Secondary"), sep = "/", remove = T, fill = "right")
Outcomes$Breed.Secondary[is.na(Outcomes$Breed.Secondary)] <- Outcomes$Breed.Primary[is.na(Outcomes$Breed.Secondary)]

# Blank string become NA
Outcomes[Outcomes==""] <- NA

# Transform results
Outcomes <- Outcomes %>%
  # Read in date column as a date
  mutate(Outcome.Date = mdy(Outcome.Date)) %>% 
  # Only select cats and dogs
  filter(Animal.Type %in% c("Cat", "Dog")) %>%
  # Clean up the List of breeds and outcomes
  mutate(Outcome.Type = ifelse(Outcome.Type %in% c("Adoption", "Euthanasia", "Return to Owner", "Transfer"), 
                               Outcome.Type, "Other"))
    

# Splits the "Sex.upon.Outcome" column into two columns, sex and spay/neuter
Outcomes <- SN_Sex_replacer(Outcomes)

# If a breed has less that 'cutoff' instances, then it becomes known as "other"
# Outcomes <- simple_breed(Outcomes, cutoff = 10)

# Creates the 'Age' vector in days
Outcomes <- separate(Outcomes, col = Age.upon.Outcome, into = c("Age.Num", "Age.Unit"), sep = " ", remove = T, fill = "right")
Outcomes$Age <- ifelse(Outcomes$Age.Unit=="years"  | Outcomes$Age.Unit=="year",  365, 0)
Outcomes$Age <- ifelse(Outcomes$Age.Unit=="months" | Outcomes$Age.Unit=="month", 30,  Outcomes$Age)
Outcomes$Age <- ifelse(Outcomes$Age.Unit=="weeks"  | Outcomes$Age.Unit=="week",  7,   Outcomes$Age)
Outcomes$Age <- ifelse(Outcomes$Age.Unit=="days"   | Outcomes$Age.Unit=="day",   1,   Outcomes$Age)
Outcomes$Age <- Outcomes$Age * as.numeric(Outcomes$Age.Num)



# Make these columns factors
Outcomes$Outcome.Type     = as.factor(Outcomes$Outcome.Type)
Outcomes$Outcome.Subtype  = as.factor(Outcomes$Outcome.Subtype )
Outcomes$Animal.Type      = as.factor(Outcomes$Animal.Type )
Outcomes$Animal.ID        = as.factor(Outcomes$Animal.ID)

High Level Outcome Numbers

Figure 01: Histogram of each Outcome Type, grouped by Sex


Figure 02: Histogram of each Outcome Type, grouped by Species


Figure 03: Boxplots (top) and Violin plots (bottom) of each Age & Species, grouped by Outcome Type

The figure has three parts with different sclaes on the y-axis:

  1. Part A measuring Age in years
  2. Part B measuring Age in months
  3. Part C measuring Age in weeks

All three figures represnet the same dataset, so don’t be confused!


Outcomes Over The Course Of The Year

Figure 04: Frequency of Outcome Type over the time period of one year


Cats

Figure 05(a): Heatmap representing the total count of cats with each Outcome Type on a month by month interval
Figure 05(b): Heatmap representing the density of each Outcome Type in respect to the month (cats only)

Dogs

Figure 05(c): Heatmap representing the total count of dogs with each Outcome Type on a month by month interval
Figure 05(d): Heatmap representing the density of each Outcome Subtype in respect to the month (dogs only). Note that the density calculation is grouped by Outcome Subtype not Outcome Type like Figure 05(c)


Outcomes By Breed

Cats

Figure 06(a): This figure illustrates the number of cats that exit AAC by Breed. Each bar is further broken down by color representing the number of cats with each Outcome Type
Figure 06(b): A similar view as Figure 06(a), but instead of stacking the Outcome Types, we facet by the types
Figure 06(c): This figure demonstrates the relitive distribution of Outcome Type by measuring the density for each Breed


Dogs

Figure 07(a): This figure illustrates the number of dogs that exit AAC by Breed. Each bar is further broken down by color representing the number of dogs with each Outcome Type
Figure 07(b): A similar view as Figure 07(a), but instead of stacking the Outcome Type, we facet by the types
Figure 07(c): This figure demonstrates the relitive distribution of Outcome Type by measuring the density for each Breed


Euthanasia Reasons

Cats

Figure 08(a): Heatmap of the count of cats euthanized, broken down by Breed and Reason. The figure is also annotated with a number representing the percentage of that breed with each particular Outcome Subtype (i.e. reason for euthanasia) relative to the total number of animals of that breed who leave the shelter

Dogs

Figure 08(b): Heatmap of the count of dogs euthanized, broken down by Breed and Reason. The figure is also annotated with a number representing the percentage of that breed with each particular Outcome Subtype (i.e. reason for euthanasia) relative to the total number of animals of that breed who leave the shelter





Contact

Hunter Ratliff

Email: hunter.ratliff@austinpetsalive.org
Twitter: @HunterRatliff1

Copyright (C) 2015 Hunter Ratliff

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.