library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
noise_data <- read.csv("~/Downloads/INF002684 FOI002773.csv") %>%
  select(type = Type, datetime = Received.Date.and.Time) %>%
  mutate(datetime = as.POSIXct(datetime, format = "%d/%m/%Y %H:%M:%S"),
         day = yday(datetime),
         month = month(datetime),
         hour = hour(datetime),
         type = ifelse(type == "Noise - Construction", "Construction", type),
         type = ifelse(type == "Noise - parties", "Party", type)) %>%
  filter(!type %in% c("", "Other", "Noise - Other"))

Top noise complaint categories in 2023

noise_data %>%
  count(type, sort = TRUE) %>%
  filter(n > 12) %>%
  arrange(n) %>%
  ggplot(aes(reorder(type, n), y = n)) +
  coord_flip() +
  geom_col() +
  labs(title = "Top noise categories", x = "", y = "Complaint volume")

Noise complaint variability over 2023

noise_data %>%
  add_count(type) %>%
  filter(n > 60) %>%
  ungroup() %>%
  count(type, month) %>%
  ggplot(aes(month, n, colour = type)) +
  geom_line() +
  labs(title = "Noise variability over year", x = "Month", y = "Complaint volume")

What times were noise complaints made

noise_data %>%
  mutate(type = fct_lump(type, 5)) %>%
  add_count(hour)%>%
  ggplot(aes(hour,n,fill = type)) +
  geom_col() +
  labs(title = "Noise data by hour", x = "Hour", y = "Complaint volume")