Rows: 4029 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (9): Record Create Date, Patrol Borough Name, County, Law Code Category ...
dbl (4): Full Complaint ID, Complaint Year Number, Month Number, Complaint P...
lgl (1): Arrest Date
ℹ 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.
#Clean up datanames(hatecrimes) <-tolower(names(hatecrimes))names(hatecrimes) <-gsub(" ","",names(hatecrimes))head(hatecrimes)
# Visualize these counts as a bar graphggplot(hatecrimes, aes(x = biasmotivedescription))+geom_bar()
# Use inlcusion/exclusion criteria to filterbias_count |>head(10) |>ggplot(aes(x=biasmotivedescription, y= n)) +geom_col()
# Arrange the bars according to height and rotatebias_count |>head(10) |>ggplot(aes(x=reorder(biasmotivedescription, n),y = n))+geom_col() +coord_flip()
# Add title, caption for the data source, and x-axis labelbias_count |>head(10) |>ggplot(aes(x=reorder(biasmotivedescription, n), y=n))+geom_col() +coord_flip() +labs(x ="",y ="Counts of hatecrime types based on motive",title ="Bar Graph of Hate Crimes from 2019-2026",subtitle ="Counts based on hatecrime motive",caption ="Source: NY State Divsion of Criminal Justice Services")
# Add color and change themebias_count |>head(10) |>ggplot(aes(x=reorder(biasmotivedescription, n), y= n)) +geom_col(fill ="salmon") +coord_flip() +labs(x="",y ="Counts of haatecrime types based on motive",title ="Bar Graph of Hate Crimes from 2019-2026",subtitle ="Counts based on the hatecrime motive",caption ="Source: NY State Division of Criminal Justice Services") +theme_minimal()
# Add annotations for counts and remove the x-axis valuesbias_count |>head(10) |>ggplot(aes(x=reorder(biasmotivedescription, n), y = n)) +geom_col(fill ="salmon") +coord_flip() +labs(x ="",y="Counts of hatecrime types based on motive",title ="Bar Graph of Hate Crimes from 2019-2026",subtitle ="Counts based on the hatecrime motive",caption ="Source: NY State Division of Criminal Justice Services") +theme_minimal() +geom_text(aes(label = n), hjust =-.05, size =3) +theme(axis.text.x =element_blank())
# Look deeper into crimes against Jewish, Asian, Black people, and gay maleshate_year <- hatecrimes |>filter(biasmotivedescription %in%c("ANTI-JEWISH", "ANTI-MALE HOMOSEXUAL (GAY", "ANTI-ASIAN", "ANTI-BLACK")) |>group_by(complaintyearnumber) |>count(biasmotivedescription) |>arrange(desc(n))hate_year
# A tibble: 20 × 3
# Groups: county [5]
county biasmotivedescription n
<chr> <chr> <int>
1 KINGS ANTI-JEWISH 798
2 NEW YORK ANTI-JEWISH 651
3 QUEENS ANTI-JEWISH 289
4 NEW YORK ANTI-MALE HOMOSEXUAL (GAY) 237
5 NEW YORK ANTI-ASIAN 228
6 KINGS ANTI-MALE HOMOSEXUAL (GAY) 120
7 KINGS ANTI-BLACK 99
8 BRONX ANTI-JEWISH 92
9 QUEENS ANTI-MALE HOMOSEXUAL (GAY) 91
10 KINGS ANTI-ASIAN 80
11 NEW YORK ANTI-BLACK 79
12 QUEENS ANTI-ASIAN 78
13 RICHMOND ANTI-JEWISH 76
14 QUEENS ANTI-BLACK 75
15 BRONX ANTI-MALE HOMOSEXUAL (GAY) 35
16 RICHMOND ANTI-BLACK 35
17 BRONX ANTI-BLACK 27
18 BRONX ANTI-ASIAN 10
19 RICHMOND ANTI-MALE HOMOSEXUAL (GAY) 6
20 RICHMOND ANTI-ASIAN 5
# Check information combining totals from counties and years hate2 <- hatecrimes |>filter(biasmotivedescription %in%c("ANTI-JEWISH", "ANTI-MALE HOMOSEXUAL (GAY)", "ANTI-ASIAN", "ANTI-BLACK"))|>group_by(complaintyearnumber, county) |>count(biasmotivedescription)|>arrange(desc(n))hate2
# A tibble: 127 × 4
# Groups: complaintyearnumber, county [35]
complaintyearnumber county biasmotivedescription n
<dbl> <chr> <chr> <int>
1 2024 KINGS ANTI-JEWISH 152
2 2024 NEW YORK ANTI-JEWISH 136
3 2025 KINGS ANTI-JEWISH 136
4 2019 KINGS ANTI-JEWISH 128
5 2023 KINGS ANTI-JEWISH 126
6 2022 KINGS ANTI-JEWISH 125
7 2023 NEW YORK ANTI-JEWISH 124
8 2025 NEW YORK ANTI-JEWISH 110
9 2022 NEW YORK ANTI-JEWISH 104
10 2021 NEW YORK ANTI-ASIAN 84
# ℹ 117 more rows
# Plot these three types of hate crimes togetherggplot(data = hate2) +geom_bar(aes(x=complaintyearnumber, y=n, fill = biasmotivedescription),position ="dodge", stat ="identity") +labs(fill ="Hate Crime Type",y ="Number of Hate Crime Incidents",title ="Hate Crime Type in NY Counties Between 2010-2016",caption ="Source: NY State Division of Criminal Justice Services")
# Counties ggplot(data = hate2) +geom_bar(aes(x=county, y=n, fill = biasmotivedescription),position ="dodge", stat ="identity") +labs(fill ="Hate Crime Type",y ="Number of Hate Crime Incidents",title ="Hate Crime Type in NY Counties Between 2010-2016",caption ="Source: NY State Division of Criminal Justice Services")
# Put it all together with years and counties using "facet"ggplot(data = hate2) +geom_bar(aes(x=complaintyearnumber, y=n, fill = biasmotivedescription),position ="dodge", stat ="identity") +facet_wrap(~county) +labs(fill ="Hate Crime Type",y ="Number of Hate Crime Incidents",title ="Hate Crime Type in NY Counties Between 2010-2016",caption ="Source: NY State Division of Criminal Justice Services")
# See how calculations can be affected by looking at hate crimes in counties per year by population densities nypop <-read_csv("nyc_census_pop_2020.csv")
Rows: 62 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): Area Name, Population Percent Change
num (2): 2020 Census Population, Population Change
ℹ 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.
# Clean the county name to match the other datasetnypop$`Area Name`<-gsub(" County", "", nypop$`Area Name`)nypop2 <- nypop |>rename(county =`Area Name`)|>select(county, `2020 Census Population`)head(nypop2)
# A tibble: 6 × 2
county `2020 Census Population`
<chr> <dbl>
1 Albany 314848
2 Allegany 46456
3 Bronx 1472654
4 Broome 198683
5 Cattaraugus 77042
6 Cayuga 76248
# Join hate2 data with nypopdatajoin <-left_join(hate2, nypop2, by=c("county"))datajoin
# A tibble: 127 × 5
# Groups: complaintyearnumber, county [35]
complaintyearnumber county biasmotivedescription n 2020 Census Populati…¹
<dbl> <chr> <chr> <int> <dbl>
1 2024 KINGS ANTI-JEWISH 152 NA
2 2024 NEW Y… ANTI-JEWISH 136 NA
3 2025 KINGS ANTI-JEWISH 136 NA
4 2019 KINGS ANTI-JEWISH 128 NA
5 2023 KINGS ANTI-JEWISH 126 NA
6 2022 KINGS ANTI-JEWISH 125 NA
7 2023 NEW Y… ANTI-JEWISH 124 NA
8 2025 NEW Y… ANTI-JEWISH 110 NA
9 2022 NEW Y… ANTI-JEWISH 104 NA
10 2021 NEW Y… ANTI-ASIAN 84 NA
# ℹ 117 more rows
# ℹ abbreviated name: ¹`2020 Census Population`
# Error, the new column has NA Valueshate_new <- hate2 |>mutate(county =as_factor(str_to_lower(as.character(county))))nypop_new <- nypop2 |>mutate(county =as_factor(str_to_lower(as.character(county))))
# A tibble: 127 × 5
# Groups: complaintyearnumber, county [35]
complaintyearnumber county biasmotivedescription n 2020 Census Populati…¹
<dbl> <fct> <chr> <int> <dbl>
1 2024 kings ANTI-JEWISH 152 2736074
2 2024 new y… ANTI-JEWISH 136 1694251
3 2025 kings ANTI-JEWISH 136 2736074
4 2019 kings ANTI-JEWISH 128 2736074
5 2023 kings ANTI-JEWISH 126 2736074
6 2022 kings ANTI-JEWISH 125 2736074
7 2023 new y… ANTI-JEWISH 124 1694251
8 2025 new y… ANTI-JEWISH 110 1694251
9 2022 new y… ANTI-JEWISH 104 1694251
10 2021 new y… ANTI-ASIAN 84 1694251
# ℹ 117 more rows
# ℹ abbreviated name: ¹`2020 Census Population`
# Calculate the rate of incidents per 100,000. Then arrange in descending orderdatajoinrate <- datajoin |>mutate(rate = n/`2020 Census Population`*100000) |>arrange(desc(rate))datajoinrate
# A tibble: 127 × 6
# Groups: complaintyearnumber, county [35]
complaintyearnumber county biasmotivedescription n 2020 Census Populati…¹
<dbl> <fct> <chr> <int> <dbl>
1 2024 new y… ANTI-JEWISH 136 1694251
2 2023 new y… ANTI-JEWISH 124 1694251
3 2025 new y… ANTI-JEWISH 110 1694251
4 2022 new y… ANTI-JEWISH 104 1694251
5 2024 kings ANTI-JEWISH 152 2736074
6 2025 kings ANTI-JEWISH 136 2736074
7 2021 new y… ANTI-ASIAN 84 1694251
8 2021 new y… ANTI-JEWISH 84 1694251
9 2019 kings ANTI-JEWISH 128 2736074
10 2023 kings ANTI-JEWISH 126 2736074
# ℹ 117 more rows
# ℹ abbreviated name: ¹`2020 Census Population`
# ℹ 1 more variable: rate <dbl>
At the end of your markdown/Quarto file with the hatecrimes code, include an essay of about 150-200 words which that answers the following questions:
Write about the positive and negative aspects of this hatecrimes dataset.
List 2 different paths you would like to (hypothetically) study about this dataset.
The positive and negative aspects of this hate crimes data set are that it’s in a legible order to read and understand with the rates being descending. However, just looking at the data set can be confusing to understand because if a person doesn’t know anything about the data, it’s not clear what “n” is. Additionally, I believe it would’ve been more helpful to display the final data set as a graph so it’s easier to understand. It’s not realistic for someone to look through all 127 rows of data to see a trend, so a graph would make it easier. Furthermore, just by the data it’s hard to see if there’s a trend or correlation going on. For example, I think the graphs for Hate Crime Type in NY Counties Between 2010-2016 were very informative and easy to understand. The two different paths I would like to hypothetically study about this data set are the ethnicity populations/distributions on each county to see if it correlates, and I would also like to study more about the history or previous education system of each county.