The Dataset

This project uses U.S. State-Level Data on Gun Laws and Crime Rates (1977–1999)

Source:https://vincentarelbundock.github.io/Rdatasets/datasets.html

Size: 1,173 rows × 14 variables

Main columns:

  • Crime rates: violent, murder, robbery

  • Demographics: race, gender, population,

  • income presence of a gun law

All crime values are rates per 100,000 people

Brief Overview

We analyzed U.S. state-level data on gun laws and crime rates from 1977–1999.

The layout includes:

  • Scatter Plot: Examines the relationship between average income and violent crime rates across states, with color indicating the presence or absence of gun laws.

  • Box Plot: Compares murder rates between states with and without gun laws.

  • 3D Plot: Visualizes interactions between violent crime, prisoner population, and income.

  • Interactive Plot: Explores violent crime rates over time for selected states.

  • Statistical Analysis

Scatter Plot (3 Variables)

The following scatter plot shows the relationship between income, violent crime rates, and the presence of gun laws in the US.

Scatter Plot Code

Below is the R code used to create the scatter plot, which visualizes the relationship between income, violent crime rates, and the presence of gun laws across U.S. states.

ggplot1 <- ggplot(Guns, aes(x = income, y = violent, color = law)) 
+ geom_point(size = 3, alpha = 0.7) 
+ labs(title = "Crime vs Income by Gun Law Status",x = "Average Income (USD)", y = "Violent Crime Rate", color = "Gun Law") 
+theme_minimal()

Boxplot

This box Plot compares murder rates between states with and without gun laws.

3D Scatter Plot

The following 3D Plot visualizes the relationship between violent crime, prisoner population, and income by gun law.

Bar Chart

This bar chart shows violent crime rates over time for selected states.

Statistical Analysis

We calculated descriptive statistics for three major types of crime: violent crime, murder, and robbery. Among these, violent crime shows the highest rates, while murder has the lowest. Violent crime rates vary greatly, ranging from 47 to over 2,900 per 100,000 people. Overall, the large gap between minimum and maximum values suggests that socioeconomic factors may strongly influence crime trends across states and years

##     violent           murder          robbery      
##  Min.   :  47.0   Min.   : 0.200   Min.   :   6.4  
##  1st Qu.: 283.1   1st Qu.: 3.700   1st Qu.:  71.1  
##  Median : 443.0   Median : 6.400   Median : 124.1  
##  Mean   : 503.1   Mean   : 7.665   Mean   : 161.8  
##  3rd Qu.: 650.9   3rd Qu.: 9.800   3rd Qu.: 192.7  
##  Max.   :2921.8   Max.   :80.600   Max.   :1635.1

Conclusion

Based on the plots, there appears to be a general trend between income levels and crime rates across U.S. states. There is also a positive correlation between higher prisoner counts and higher violent crime rates. The presence of gun laws appears to lower crime rates, suggesting that policy interventions can have a impact on public safety. Among the selected states, Washington, D.C. reports the highest violent crime rate, followed by states such as New York and California.