## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.2
## ✔ ggplot2 4.0.0 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── 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
##
## Attaching package: 'scales'
##
## The following object is masked from 'package:purrr':
##
## discard
##
## The following object is masked from 'package:readr':
##
## col_factor
This report analyzes the crime trends in Victoria, Australia with the help of open data. The dataset has yearly counts of recorded offences which are grouped by offence types and drug classifications. The aim is to find the main trends, to know about the most frequent offences, and visualize the patterns int he crime based on the time.
| 2. Load and Inspect the Data |
## Rows: 2133 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): Year ending, Offence Subdivision, Offence Group, Offence Descriptio...
## dbl (2): Year, Offence Count
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 2,133
## Columns: 7
## $ Year <dbl> 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 20…
## $ Year.ending <chr> "June", "June", "June", "June", "June", "June", "J…
## $ Offence.Subdivision <chr> "C10 Drug dealing and trafficking", "C10 Drug deal…
## $ Offence.Group <chr> "C11 Drug dealing", "C11 Drug dealing", "C11 Drug …
## $ Offence.Description <chr> "INTRODUCE DRUG INTO REMAND CENTRE", "KNOWGLY CAUS…
## $ CSA.Drug.Type <chr> "Not Recorded", "Not Recorded", "Not Recorded", "N…
## $ Offence.Count <dbl> 2, 3, 1, 1, 7, 8, 49, 1, 1, 1, 3, 4, 2, 3, 2, 8, 2…
# Handle missing and data types
crime <- crime %>%
filter(!is.na(Offence.Count)) %>%
mutate(Year = as.numeric(Year))
summary(crime)## Year Year.ending Offence.Subdivision Offence.Group
## Min. :2016 Length:2133 Length:2133 Length:2133
## 1st Qu.:2018 Class :character Class :character Class :character
## Median :2020 Mode :character Mode :character Mode :character
## Mean :2020
## 3rd Qu.:2023
## Max. :2025
## Offence.Description CSA.Drug.Type Offence.Count
## Length:2133 Length:2133 Min. : 1.0
## Class :character Class :character 1st Qu.: 2.0
## Mode :character Mode :character Median : 6.0
## Mean : 150.3
## 3rd Qu.: 27.0
## Max. :10244.0
crime_summary <- crime %>%
group_by(Year) %>%
summarise(total_offences = sum(Offence.Count, na.rm = TRUE))
ggplot(crime_summary, aes(x = Year, y = total_offences)) +
geom_line(color = "steelblue", linewidth = 1.2) +
geom_point(size = 2) +
labs(
title = "Total Recorded Offences Over Time",
x = "Year", y = "Number of Offences"
) +
scale_y_continuous(labels = comma)group_trend <- crime %>%
group_by(Year, Offence.Group) %>%
summarise(total_offences = sum(Offence.Count, na.rm = TRUE)) %>%
ungroup()## `summarise()` has grouped output by 'Year'. You can override using the
## `.groups` argument.
ggplot(group_trend, aes(x = Year, y = total_offences, color = Offence.Group)) +
geom_line(linewidth = 1) +
geom_point(size = 1.5) +
labs(
title = "Trends of Major Offence Groups Over Time",
x = "Year", y = "Number of Offences",
color = "Offence Group"
) +
scale_y_continuous(labels = comma)top_offences <- crime %>%
group_by(Offence.Description) %>%
summarise(total_offences = sum(Offence.Count, na.rm = TRUE)) %>%
arrange(desc(total_offences)) %>%
slice_head(n = 10)
ggplot(top_offences, aes(x = reorder(Offence.Description, total_offences), y = total_offences)) +
geom_col(fill = "tomato") +
coord_flip() +
labs(
title = "Top 10 Most Common Offence Descriptions",
x = "Offence Description", y = "Total Offences"
) +
scale_y_continuous(labels = comma)if("CSA.Drug.Type" %in% names(crime)) {
drug_data <- crime %>%
filter(!is.na(CSA.Drug.Type)) %>%
group_by(CSA.Drug.Type) %>%
summarise(total = sum(Offence.Count, na.rm = TRUE)) %>%
arrange(desc(total))
ggplot(drug_data, aes(x = reorder(CSA.Drug.Type, total), y = total)) +
geom_col(fill = "darkorange") +
coord_flip() +
labs(
title = "Drug-Related Offences by Drug Type",
x = "CSA Drug Type", y = "Total Offences"
) +
scale_y_continuous(labels = comma)
}Year 2020 has the highest offence. Then in the year 2022. the offence is decreased and from 2022 the offence started to increase gradually.
Mainly due to the drug possession, the offence is high in all the year.
The top offence is possess cannabis, followed by possess methlamphetamine, followed by possess drug of defend-prescript drug, followed by traffick methylamphetamine, followed by possess heroin, rollowed by cultivate narcotic plant-cannabis, followed by possess drug of dependence (not named), followed by possess ecstasy, followed by traffick cannabis and followed by possess GHB.
The main reason for the offence is the Drug type cannabi. Next to cannabis methylamphetamine, followed by prescription are the drug types which can lead to drug related offences.
The visualizations shows the trend in the total number of offences over time, The dominance of specific offence groups and The concentration of certain drug-related crimes. These insights are used by the policymakers and law enforcement agencies for allocation of the resources and for preventing the techniques in an effective way.
Team, R. C. (2000). R language definition. Vienna, Austria: R foundation for statistical computing, 3(1), 116. https://mirror.twds.com.tw/CRAN/doc/FAQ/r-release/R-lang.pdf
Cheam, A. H., & Code, G. R. (1995). The biology of Australian weeds 24. Raphanus raphanistrum L. Plant Protection Quarterly, 10, 2-2. https://caws.org.nz/PPQ8910/PPQ%2010-1%20pp002-13%20Cheam.pdf
Arel-Bundock, V., Enevoldsen, N., & Yetman, C. J. (2018). countrycode: An R package to convert country names and country codes. Journal of Open Source Software, 3(28), 848. https://joss.theoj.org/papers/10.21105/joss.00848.pdf
Codes, S. E. P. P., Code, H., Code, R. H., Code, C. R. F., Code, S., Code, D., & Code, F. S. (1963). Part A. https://www.midcoast.nsw.gov.au/files/assets/public/v/3/document-resources/forms-library/building-development-amp-planning-midcoast-wide/complying-development-certificate-application.pdf
Pebesma, E., & Bivand, R. S. (2005). S classes and methods for spatial data: the sp package. R news, 5(2), 9-13. http://cran.uvigo.es/web/packages/sp/vignettes/intro_sp.pdf
The dataset is collected from below url
Crime Statistics Agency Victoria (2025). Recorded Offences by Category and Year.
https://www.crimestatistics.vic.gov.au/crime-statistics/latest-victorian-crime-data/download-data
Published URL: https://rpubs.com/IhteshamAhmed/1360344