Hourly visits

hourly_visits <- visits %>% 
  mutate(
    dt = floor_date(visitStartTime, unit = "month"),
    hour_ampm = format(visitStartTime, "%I %p")) %>% 
  group_by(dt, hour_ampm) %>% 
  summarise(
    number_of_visits_per_hour = n(),
    .groups = "drop")

ggplotly(
  ggplot(hourly_visits, aes( x = dt, y = number_of_visits_per_hour, colour = hour_ampm)) +
    geom_line(aes(group = hour_ampm)) +
    geom_point(size = 1) +
    labs(
      title = "Hourly Visits",
      x = "Month",
      y = "Number of visits",
      color = "Hour (AM/PM)"))