Data preparation

area_summary <- read.csv(
  "C:/Users/RESHMI/OneDrive/Documents/DV_A2/data/melbourne_area_summary.csv"
)

head(area_summary)
##      AreaName total_records violation_records violation_rate
## 1   Docklands       5057409            256416           5.07
## 2 Queensberry       3470863            106165           3.06
## 3   Southbank       2691230             91950           3.42
## 4    Jolimont       2415712             74154           3.07
## 5         All       2042347            178257           8.73
## 6      Titles       1910619             67635           3.54
nrow(area_summary)
## [1] 38
plot_ly(
  data = area_summary,
  x = ~violation_rate,
  y = ~AreaName,
  type = "bar",
  orientation = "h",
  customdata = ~cbind(total_records, violation_records),
  hovertemplate = paste0(
    "Parking area: %{y}",
    "<br>Violation rate: %{x:.2f}%",
    "<br>Total records: %{customdata[0]:,}",
    "<br>Recorded violations: %{customdata[1]:,}",
    "<extra></extra>"
  )
) %>%
  layout(
    height = 950,
    xaxis = list(title = "Recorded violation rate (%)"),
    yaxis = list(title = "Parking area")
  )
## Warning: Specifying width/height in layout() is now deprecated.
## Please specify in ggplotly() or plot_ly()
area_summary %>%
  arrange(desc(violation_rate)) %>%
  select(
    AreaName,
    total_records,
    violation_records,
    violation_rate
  ) %>%
  head(15)
##          AreaName total_records violation_records violation_rate
## 1      Kensington           427               113          26.46
## 2          Domain        112274             11675          10.40
## 3             All       2042347            178257           8.73
## 4        Courtney        845717             52009           6.15
## 5          Family        667358             36648           5.49
## 6        McKillop        673030             36599           5.44
## 7       Docklands       5057409            256416           5.07
## 8         Windsor        737352             31702           4.30
## 9        Hardware       1092459             46823           4.29
## 10 East Melbourne        725259             30452           4.20
## 11           RACV        191850              7916           4.13
## 12 West Melbourne        767139             31344           4.09
## 13    Twin Towers        726690             28495           3.92
## 14    City Square        373315             14569           3.90
## 15      Chinatown        542385             19986           3.68
monthly_summary <- read.csv(
  "C:/Users/RESHMI/OneDrive/Documents/DV_A2/data/melbourne_monthly_summary.csv"
)

print(nrow(monthly_summary))
## [1] 12
plot_ly(
  data = monthly_summary,
  x = ~month,
  y = ~violation_rate,
  type = "scatter",
  mode = "lines+markers"
) %>%
  layout(
    xaxis = list(
      title = "Month of 2019",
      dtick = 1
    ),
    yaxis = list(
      title = "Recorded violation rate (%)"
    )
  )
library(plotly)

hourly_summary <- read.csv(
  "C:/Users/RESHMI/OneDrive/Documents/DV_A2/data/melbourne_hourly_summary.csv"
)

names(hourly_summary)
## [1] "hour"              "total_records"     "violation_records"
## [4] "violation_rate"
nrow(hourly_summary)
## [1] 24
plot_ly(
  data = hourly_summary,
  x = ~hour,
  y = ~violation_rate,
  type = "scatter",
  mode = "lines+markers"
) %>%
  layout(
    title = "Recorded Violation Rate by Arrival Hour",
    xaxis = list(
      title = "Arrival hour (0–23)",
      dtick = 1
    ),
    yaxis = list(
      title = "Recorded violation rate (%)"
    )
  )
# Step 74: Verify summary datasets

# Load all three summary datasets

area_summary <- read.csv(
  "C:/Users/RESHMI/OneDrive/Documents/DV_A2/data/melbourne_area_summary.csv"
)

monthly_summary <- read.csv(
  "C:/Users/RESHMI/OneDrive/Documents/DV_A2/data/melbourne_monthly_summary.csv"
)

hourly_summary <- read.csv(
  "C:/Users/RESHMI/OneDrive/Documents/DV_A2/data/melbourne_hourly_summary.csv"
)

# Check total records
cat("Area records:", sum(area_summary$total_records), "\n")
## Area records: 42672743
cat("Monthly records:", sum(monthly_summary$total_records), "\n")
## Monthly records: 42672743
cat("Hourly records:", sum(hourly_summary$total_records), "\n")
## Hourly records: 42672743
# Check recorded violations
cat("Area violations:", sum(area_summary$violation_records), "\n")
## Area violations: 1558893
cat("Monthly violations:", sum(monthly_summary$violation_records), "\n")
## Monthly violations: 1558893
cat("Hourly violations:", sum(hourly_summary$violation_records), "\n")
## Hourly violations: 1558893