The data set that we will be dating a look at is the Suicide Rates Overview from 1985 to 2016. The data set includes information such as country, year, sex, age, suicide count, population, generation, HDI, and GDP. Let’s make the data presentable in a more meaningful way and see what conclusions or inferences we can draw from it.
library(data.table)
library(DescTools)
library(ggplot2)
library(lubridate)
library(scales)
library(RColorBrewer)
library(ggthemes)
library(dplyr)
library(ggrepel)
library(plotly)
setwd("U:/DS736 SP24")
su_df <- fread("U:/DS736 SP24/SuicideRatesDataset.csv")
x_axis_labels <- min(su_df$year):max(su_df$year)
sum_by_year <- aggregate(suicides_no ~ year, data = su_df, FUN = sum)
hi_lo <- sum_by_year %>%
filter(suicides_no == min(suicides_no) | suicides_no == max(suicides_no)) %>%
data.frame()
pie_subset <- subset(su_df, select=c('sex', 'year', 'suicides_no'))
sum_by_country <- aggregate(suicides_no ~ country, data = su_df, FUN = sum)
top_countries <- sum_by_country[order(-sum_by_country$suicides_no), ]
top_countries <- head(top_countries)
donut_subset <- select(su_df, sex, age, suicides_no)
donut_subset$age <- factor(donut_subset$age, levels = c("5-14 years","15-24 years", "25-34 years", "35-54 years", "55-74 years", "75+ years"))
suicide_data_agg <- su_df %>%
group_by(age, year) %>%
summarise(total_suicides = sum(suicides_no))
suicide_data_agg$age <- factor(suicide_data_agg$age, levels = c("5-14 years","15-24 years", "25-34 years", "35-54 years", "55-74 years", "75+ years"))
line_plot <- ggplot(sum_by_year, aes(x=year, y=suicides_no, color=year)) +
geom_line(size=1) +
geom_point(size=3, color="orange") +
labs(title="Suicide Occurrences by Year", x="Year", y="Count") +
theme_light() +
theme(plot.title= element_text(hjust=0.5)) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
scale_x_continuous(labels=x_axis_labels,breaks= x_axis_labels) +
scale_y_continuous(labels=comma) +
geom_point(data = hi_lo, aes(x = year, y = suicides_no), shape=21) +
geom_label_repel(aes(label=ifelse(suicides_no==max(suicides_no) | suicides_no==min(suicides_no), scales::comma(suicides_no), "")),
box.padding=1,
point.padding=1,
size=4,
color='Grey50',
segment.color='darkblue')
line_plot
As seen above, we have a line plot to show the suicide count by year for each year in our data set. The data set included 32 total years with a range from 1985 to 2016. This line plot allows us to see which years had the highest frequency of suicides and which years had the least. We do not have enough information to provide a reasoning for both of those statistics but we can speculate. The year with the highest count of suicides reported a total number of 256,119 and the year with the lowest reported 15,603. I can speculate that that low count for 2016 is either due to a lack of data or lack of reporting’s. Contrarily, 1999 is the year with the highest frequency and I could speculate that may have had to do with Y2K. However, another thing worth mentioning is there doesn’t seem to be a lot of variances in frequency between the years of 1994 and 2014 but we see an interestingly large increase in frequency between 1988 and 1990.
plot_ly(top_countries, labels = ~country, values= ~suicides_no, type = "pie",
textposition="inside",
textinfo = 'label+percent',
insidetextfont = list(color = '#FFFFFF')) %>%
layout(title="Top 5 Countries for Suicide Occurrences (1985-2016)")
In this visualization, we have a pie chart displaying the Top 5 Countries for Suicide Occurrences across all years (1985-2016). We can see here that the Russian Federation is leading the countries for most suicide occurrences across those years with a total of 1,209,742. In second place, to no surprise, we have the United States with a grand total of 1,034,013 suicides. Further along, we have Japan then France then Ukraine and Germany. Only the United States and the Russian Federation have a grand total exceeding 1 million. When you hover over each pie slice, the chart provides the country name, the percent of suicides, and the total number of suicides.
bar_plot <- ggplot(donut_subset, aes(x = age, y = suicides_no, fill = sex)) +
geom_bar(stat = "identity") +
labs(title="Suicide Occurrences by Age Group and Sex", x = "Age Group", y = "Count", fill = "Sex") +
theme_minimal() +
scale_y_continuous(labels=comma) +
theme(plot.title= element_text(hjust=0.5)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
bar_plot
Above is a stacked bar chart to show suicide counts by age group and sex. We can see that the 35-54 years age group has the highest frequency of suicides at nearly 2,500,000. They are followed by the 55-74 years age group and then the 25-34 years age group. The age group with the lowest frequency is 5-14 years, which makes a lot of sense. I personally expected the 15-24 years age group to be one of the highest frequencies as I feel those are ones most commonly heard of but I’m also not surprised that 35-54 years was the highest. Additionally, the stacked bars allow us to see the ratio of male to female for each age group and we can certainly infer that males have a higher suicide count opposed to females.
heat <- ggplot(suicide_data_agg, aes(x = year, y = age, fill = total_suicides)) +
geom_tile() +
scale_fill_viridis_c(labels = scales::comma) +
labs(title = "Heatmap of Suicides by Age Group and Year",
x = "Year",
y = "Age Group",
fill = "Total Suicides") +
theme_minimal() +
theme(plot.title= element_text(hjust=0.5)) +
scale_x_continuous(breaks = seq(min(suicide_data_agg$year), max(suicide_data_agg$year), by = 5))
heat
In this visualization, we are analyzing suicides by age group and year. In short, this heatmap serves as validation for our previous line plot and stacked bar chart because it contains the same variables and statistics. Nonetheless, I appreciate when data can confirm itself. As can be seen in the Heatmap, our legend shows the color yellow for a higher count of suicides and dark blue/purple for lower counts of suicides. So, after taking a look, we can see that the higher count of suicides is displayed over the 35-54 years age group and between the years of 1990 to 2010 approximately. Likewise, we can see that the lowest count of suicides takes place for the 5-14 years age group for all years. This reaffirms what we inferred from the previous line and bar plot: the 35-54 years age group has the highest frequency in suicides and the 5-14 years age group contains the lowest. Secondly, between the years of 1994 and 2014 approximately, there was a high frequency for suicides with little variance year to year.
donut_fig <- plot_ly(hole = 0.7) %>%
layout(title = "Suicides by Generation and Top 3 Years (1999, 2002, 2003)") %>%
add_trace(
data = subset(su_df, year == 1999),
labels = ~generation,
values = ~suicides_no,
type = "pie",
textposition = "inside",
hovertemplate = "Year: 1999<br>Generation:%{label}<br>Percent:%{percent}<br>Suicide Count: %{value}<extra></extra>"
) %>%
add_trace(
data = subset(su_df, year == 2002),
labels = ~generation,
values = ~suicides_no,
type = "pie",
textposition = "inside",
hovertemplate = "Year: 2002<br>Generation:%{label}<br>Percent:%{percent}<br>Suicide Count: %{value}<extra></extra>",
domain = list(x = c(0.16, 0.84), y = c(0.16, 0.84))
) %>%
add_trace(
data = subset(su_df, year == 2003),
labels = ~generation,
values = ~suicides_no,
type = "pie",
textposition = "inside",
hovertemplate = "Year: 2003<br>Generation:%{label}<br>Percent:%{percent}<br>Suicide Count: %{value}<extra></extra>",
domain = list(x = c(0.27, 0.73), y = c(0.27, 0.73)))
donut_fig
Lastly, we are looking at a nested donut chart showing suicide counts by generation and the top 3 years (1999, 2002, and 2003). These years had the highest frequency in suicide across all years in our data set so I decided to focus in on those years, making each year represented in its own donut with the 1999 being the outer-most and 2003 being the inner-most. Each donut reflects the suicide count for each generation within our data set and its corresponding percentage and total count for said year. Interestingly, it shows that the Boomer generation had the highest count of suicides for all three of our years here (1999, 2002, 2003), with Gen X and Silent generations following close behind. One thing I noticed right away was that 1999 was the only year showing data for the G.I. generation and I confirmed this was due to 2002 and 2003 not containing any data for that generation. This could be due to lack of suicides for that generation after 1999 or due to lack of data but I’m leaning more towards the primary since the G.I generation was born between 1901-1927.
In closing, we can conclude from our data set that 1999 was the year with the highest count of suicides at a striking total of 256,119 with little variance between 1994-2014. Secondly, we can conclude that the Russian Federation and the United States were the two leading countries for suicides counts across all years (1985-2016). Thirdly, we can conclude that there are more male suicides than female suicides. We can also conclude that the 35-54 years age group is the age group with the highest count of suicides across all years. Lastly, the Boomer generation has the most suicides and the GI generation didn’t have any reported suicides after 1999.