library(tidyverse) library(crimedata)

data(package = “crimedata”) list_crime_data()

crime_data <- get_crime_data( years = 2007, cities = “New York”, type = “sample”, cache = TRUE, quiet = !interactive(), output = “tbl” )

str(crime_data) glimpse(crime_data)

ggplot(crime_data, aes(x = offense_type)) + geom_bar() + labs( title = “Counts of Offense Types”, x = “Offense Type”, y = “Number of Incidents” ) + theme_minimal() + theme(axis.text.x = element_text(angle = 45, hjust = 1))

The bar chart shows that larceny and theft is the most common offense type in New York in 2007, with more incidents then other categories. Other offenses such as felony assault, burglary and robbery happen at a much lower rate while crimes like kidnapping and bribery are the least common. A bar chart is more appropriate than a histogram for this data because offense_type is more of a category. Bar charts are used to show and compare how often different categories occur, while histograms are for numerical data.