<iframe src="https://exploratory.io/viz/kanaugust/7999323729445690?embed=true" frameborder="0" width="100%" height="100%" > </iframe>
# Set libPaths.
.libPaths("/Users/kannishida/.exploratory/R/3.3")
# Load required packages.
library(janitor)
library(lubridate)
library(hms)
library(tidyr)
library(urltools)
library(stringr)
library(readr)
library(broom)
library(RcppRoll)
library(tibble)
library(dplyr)
library(exploratory)
# Data Analysis Steps
exploratory::read_delim_file("/Users/kannishida/Downloads/Livestock_by_Regional.csv" , ",", quote = "\"", skip = 0 , col_names = TRUE , na = c("","NA") , locale=locale(encoding = "ASCII", decimal_mark = "."), trim_ws = FALSE , progress = FALSE) %>%
exploratory::clean_data_frame() %>%
filter(!str_detect(Area, "^Total")) %>%
filter(str_detect(Livestock, "^Total")) %>%
mutate(Year = mdy(Year), Area = str_c(Area, " Region"), Area = str_replace(Area, "Hawkes", "Hawke's")) %>%
filter(year(Year) > 2000) %>%
filter(year(Year) == 2013 & !is.na(Value)) %>%
filter(Livestock == "Total sheep") %>%
left_join(Population, by = c("Area" = "Area")) %>%
filter(!is.na(Value.y)) %>%
rename(number_of_animals = Value.x, number_of_human = Value.y) %>%
mutate(sheep_human_ratio = number_of_animals / number_of_human, buckets = cut(sheep_human_ratio, breaks=c(-Inf, 1, 10, 20, 30, 40, Inf),
labels=c("Less than Human", "1-10 Times More",
"10-20 Times More", "20-30 Times More", "30-40 Times More",
"Greater than 40 Times")))
I have downloaded the data from Statistics New Zealand (http://nzdotstat.stats.govt.nz/wbos/Index.aspx) and used the population of people and sheep in 2013 for the comparison. The regional boundaries data was originally downloaded from the same website and converted to GeoJSON, which is available at Map Gallery page. (https://exploratory.io/map)