data_crime <- data.frame(
year = 2015:2024,
crime_rate = c(3200, 3300, 3500, 3700, 3900, 4200, 4500, 4700, 4900, 5100)
)
ggplot(data_crime, aes(x = year, y = crime_rate)) +
geom_line(size = 1, color = "red") +
geom_point(size = 2, color = "red") +
labs(title = "Crime Rate Over Time", x = "Year", y = "Crime Rate per 100,000 population")Unemployment
---
title: "Unemployment and Crime Rates Dashboard"
format: dashboard
editor: visual
--------------
## Overview
This dashboard presents unemployment trends and crime rate patterns using sample data. Replace the sample datasets with your actual data for real insights.
## Unemployment Rate
::: {.cell}
```{.r .cell-code}
library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.4.3
data_unemployment <- data.frame(
year = 2015:2024,
unemployment_rate = c(24.3, 25.0, 26.5, 27.1, 28.0, 29.2, 30.1, 32.5, 33.0, 32.1)
)
ggplot(data_unemployment, aes(x = year, y = unemployment_rate)) +
geom_line(size = 1) +
geom_point(size = 2) +
labs(title = "Unemployment Rate Over Time", x = "Year", y = "Unemployment Rate (%)")Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
:::
Crime Rates
Relationship Between Unemployment and Crime
combined_data <- merge(data_unemployment, data_crime, by = "year")
ggplot(combined_data, aes(x = unemployment_rate, y = crime_rate)) +
geom_point(size = 3) +
geom_smooth(method = "lm", se = FALSE) +
labs(title = "Relationship Between Unemployment and Crime", x = "Unemployment Rate (%)", y = "Crime Rate")`geom_smooth()` using formula = 'y ~ x'