Sl..No. Cause Below.14.years...Male Below.14.years...Female
1 1 Avalanche 0 0
2 2 Exposure to cold 6 4
3 3 Cyclone 1 0
4 4 Tornado 0 0
5 5 Tsunami 0 0
6 6 Earthquake 0 0
Below.14.years...Transgender Below.14.years...Total
1 0 0
2 0 10
3 0 1
4 0 0
5 0 0
6 0 0
X14.and.Above...Below.18.years...Male X14.and.Above...Below.18.years...Female
1 1 0
2 7 6
3 0 1
4 0 0
5 0 0
6 0 0
X14.and.Above...Below.18.years...Transgender
1 0
2 0
3 0
4 0
5 0
6 0
X14.and.Above...Below.18.years...Total X18.and.Above...Below.30.years...Male
1 1 23
2 13 68
3 1 0
4 0 0
5 0 0
6 0 0
X18.and.Above...Below.30.years...Female
1 0
2 12
3 0
4 0
5 0
6 0
X18.and.Above...Below.30.years...Transgender
1 0
2 0
3 0
4 0
5 0
6 0
X18.and.Above...Below.30.years...Total X30.and.Above...Below.45.years...Male
1 23 5
2 80 187
3 0 4
4 0 0
5 0 0
6 0 0
X30.and.Above...Below.45.years...Female
1 0
2 21
3 0
4 0
5 0
6 0
X30.and.Above...Below.45.years...Transgender
1 0
2 3
3 0
4 0
5 0
6 0
X30.and.Above...Below.45.years...Total X45.and.Above.Below.60.years...Male
1 5 0
2 211 205
3 4 1
4 0 0
5 0 0
6 0 0
X45.and.Above.Below.60.years...Female
1 0
2 39
3 1
4 0
5 0
6 0
X45.and.Above.Below.60.years...Transgender
1 0
2 0
3 0
4 0
5 0
6 0
X45.and.Above.Below.60.years...Total X60.years...Above...Male
1 0 0
2 244 132
3 2 1
4 0 0
5 0 0
6 0 0
X60.years...Above...Female X60.years...Above...Transgender
1 0 0
2 30 0
3 0 0
4 0 0
5 0 0
6 0 0
X60.years...Above...Total Total...Male Total...Female Total...Transgender
1 0 29 0 0
2 162 605 112 3
3 1 7 2 0
4 0 0 0 0
5 0 0 0 0
6 0 0 0 0
Total...Total Total...Percentage.Share
1 29 0.4
2 720 8.9
3 9 0.1
4 0 0.0
5 0 0.0
6 0 0.0
Sl..No. Cause Below.14.years...Male
Length:15 Length:15 Min. : 0.00
Class :character Class :character 1st Qu.: 0.00
Mode :character Mode :character Median : 6.00
Mean : 43.87
3rd Qu.: 46.00
Max. :329.00
Below.14.years...Female Below.14.years...Transgender Below.14.years...Total
Min. : 0.00 Min. :0 Min. : 0.0
1st Qu.: 0.00 1st Qu.:0 1st Qu.: 0.0
Median : 1.00 Median :0 Median : 8.0
Mean : 17.73 Mean :0 Mean : 61.6
3rd Qu.: 18.00 3rd Qu.:0 3rd Qu.: 69.5
Max. :133.00 Max. :0 Max. :462.0
X14.and.Above...Below.18.years...Male X14.and.Above...Below.18.years...Female
Min. : 0.00 Min. : 0
1st Qu.: 0.00 1st Qu.: 0
Median : 4.00 Median : 3
Mean : 31.47 Mean : 14
3rd Qu.: 10.00 3rd Qu.: 7
Max. :236.00 Max. :105
X14.and.Above...Below.18.years...Transgender
Min. :0
1st Qu.:0
Median :0
Mean :0
3rd Qu.:0
Max. :0
X14.and.Above...Below.18.years...Total X18.and.Above...Below.30.years...Male
Min. : 0.00 Min. : 0.0
1st Qu.: 0.00 1st Qu.: 0.0
Median : 7.00 Median : 23.0
Mean : 45.47 Mean :125.7
3rd Qu.: 17.00 3rd Qu.: 85.0
Max. :341.00 Max. :943.0
X18.and.Above...Below.30.years...Female
Min. : 0.0
1st Qu.: 0.0
Median : 5.0
Mean : 35.6
3rd Qu.: 19.0
Max. :267.0
X18.and.Above...Below.30.years...Transgender
Min. :0.0000
1st Qu.:0.0000
Median :0.0000
Mean :0.5333
3rd Qu.:0.5000
Max. :4.0000
X18.and.Above...Below.30.years...Total X30.and.Above...Below.45.years...Male
Min. : 0.0 Min. : 0.0
1st Qu.: 0.0 1st Qu.: 1.0
Median : 23.0 Median : 15.0
Mean : 161.9 Mean : 200.1
3rd Qu.: 104.0 3rd Qu.: 182.5
Max. :1214.0 Max. :1501.0
X30.and.Above...Below.45.years...Female
Min. : 0.0
1st Qu.: 0.0
Median : 7.0
Mean : 53.6
3rd Qu.: 27.5
Max. :402.0
X30.and.Above...Below.45.years...Transgender
Min. :0.0000
1st Qu.:0.0000
Median :0.0000
Mean :0.6667
3rd Qu.:0.5000
Max. :5.0000
X30.and.Above...Below.45.years...Total X45.and.Above.Below.60.years...Male
Min. : 0.0 Min. : 0.0
1st Qu.: 1.0 1st Qu.: 0.0
Median : 22.0 Median : 15.0
Mean : 254.4 Mean : 158.8
3rd Qu.: 210.0 3rd Qu.: 201.5
Max. :1908.0 Max. :1191.0
X45.and.Above.Below.60.years...Female
Min. : 0.0
1st Qu.: 0.0
Median : 11.0
Mean : 46.4
3rd Qu.: 35.0
Max. :348.0
X45.and.Above.Below.60.years...Transgender
Min. :0.0000
1st Qu.:0.0000
Median :0.0000
Mean :0.6667
3rd Qu.:0.0000
Max. :5.0000
X45.and.Above.Below.60.years...Total X60.years...Above...Male
Min. : 0.0 Min. : 0.0
1st Qu.: 0.0 1st Qu.: 0.0
Median : 29.0 Median : 3.0
Mean : 205.9 Mean : 288.5
3rd Qu.: 243.5 3rd Qu.: 128.5
Max. :1544.0 Max. :2164.0
X60.years...Above...Female X60.years...Above...Transgender
Min. : 0.00 Min. :0.0000
1st Qu.: 0.00 1st Qu.:0.0000
Median : 4.00 Median :0.0000
Mean : 56.67 Mean :0.2667
3rd Qu.: 30.00 3rd Qu.:0.0000
Max. :425.00 Max. :2.0000
X60.years...Above...Total Total...Male Total...Female Total...Transgender
Min. : 0.0 Min. : 0.0 Min. : 0 Min. : 0.000
1st Qu.: 0.0 1st Qu.: 3.5 1st Qu.: 0 1st Qu.: 0.000
Median : 8.0 Median : 54.0 Median : 34 Median : 0.000
Mean : 345.5 Mean : 848.5 Mean : 224 Mean : 2.133
3rd Qu.: 159.0 3rd Qu.: 601.5 3rd Qu.: 131 3rd Qu.: 1.500
Max. :2591.0 Max. :6364.0 Max. :1680 Max. :16.000
Total...Total Total...Percentage.Share
Min. : 0.0 Min. : 0.00
1st Qu.: 3.5 1st Qu.: 0.05
Median : 89.0 Median : 1.10
Mean :1074.7 Mean : 13.33
3rd Qu.: 725.0 3rd Qu.: 9.00
Max. :8060.0 Max. :100.00
Sl..No. Cause Below.14.years...Male
1 1 Avalanche 0
2 2 Exposure to cold 6
3 3 Cyclone 1
4 4 Tornado 0
5 5 Tsunami 0
6 6 Earthquake 0
7 7 Epidemic 0
8 8 Flood 76
9 9 Heat/Sun Stroke 9
10 10 Landslide 16
11 11 Lightning 127
12 12 Torrential Rain 7
13 13 Forest Fire 0
14 14 Causes other than above 87
15 Total Total 329
Below.14.years...Female Below.14.years...Transgender Below.14.years...Total
1 0 0 0
2 4 0 10
3 0 0 1
4 0 0 0
5 0 0 0
6 0 0 0
7 0 0 0
8 48 0 124
9 8 0 17
10 21 0 37
11 36 0 163
12 1 0 8
13 0 0 0
14 15 0 102
15 133 0 462
X14.and.Above...Below.18.years...Male
1 1
2 7
3 0
4 0
5 0
6 0
7 0
8 67
9 13
10 4
11 133
12 4
13 0
14 7
15 236
X14.and.Above...Below.18.years...Female
1 0
2 6
3 1
4 0
5 0
6 0
7 0
8 19
9 8
10 4
11 59
12 3
13 0
14 5
15 105
X14.and.Above...Below.18.years...Transgender
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
11 0
12 0
13 0
14 0
15 0
X14.and.Above...Below.18.years...Total X18.and.Above...Below.30.years...Male
1 1 23
2 13 68
3 1 0
4 0 0
5 0 0
6 0 0
7 0 0
8 86 102
9 21 59
10 8 48
11 192 521
12 7 10
13 0 0
14 12 112
15 341 943
X18.and.Above...Below.30.years...Female
1 0
2 12
3 0
4 0
5 0
6 0
7 0
8 26
9 16
10 16
11 170
12 5
13 0
14 22
15 267
X18.and.Above...Below.30.years...Transgender
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 2
10 0
11 1
12 0
13 0
14 1
15 4
X18.and.Above...Below.30.years...Total X30.and.Above...Below.45.years...Male
1 23 5
2 80 187
3 0 4
4 0 0
5 0 0
6 0 0
7 0 0
8 128 76
9 77 178
10 64 78
11 692 721
12 15 15
13 0 2
14 135 235
15 1214 1501
X30.and.Above...Below.45.years...Female
1 0
2 21
3 0
4 0
5 0
6 0
7 0
8 14
9 31
10 24
11 270
12 7
13 0
14 35
15 402
X30.and.Above...Below.45.years...Transgender
1 0
2 3
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 1
11 1
12 0
13 0
14 0
15 5
X30.and.Above...Below.45.years...Total X45.and.Above.Below.60.years...Male
1 5 0
2 211 205
3 4 1
4 0 0
5 0 0
6 0 0
7 0 0
8 90 61
9 209 214
10 103 30
11 992 465
12 22 15
13 2 2
14 270 198
15 1908 1191
X45.and.Above.Below.60.years...Female
1 0
2 39
3 1
4 0
5 0
6 0
7 0
8 14
9 31
10 11
11 193
12 14
13 0
14 45
15 348
X45.and.Above.Below.60.years...Transgender
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 5
10 0
11 0
12 0
13 0
14 0
15 5
X45.and.Above.Below.60.years...Total X60.years...Above...Male
1 0 0
2 244 132
3 2 1
4 0 0
5 0 0
6 0 0
7 0 0
8 75 27
9 250 125
10 41 8
11 658 149
12 29 3
13 2 3
14 243 1716
15 1544 2164
X60.years...Above...Female X60.years...Above...Transgender
1 0 0
2 30 0
3 0 0
4 0 0
5 0 0
6 0 0
7 0 0
8 17 0
9 30 1
10 8 0
11 41 0
12 4 1
13 0 0
14 295 0
15 425 2
X60.years...Above...Total Total...Male Total...Female Total...Transgender
1 0 29 0 0
2 162 605 112 3
3 1 7 2 0
4 0 0 0 0
5 0 0 0 0
6 0 0 0 0
7 0 0 0 0
8 44 409 138 0
9 156 598 124 8
10 16 184 84 1
11 190 2116 769 2
12 8 54 34 1
13 3 7 0 0
14 2011 2355 417 1
15 2591 6364 1680 16
Total...Total Total...Percentage.Share Percentage_of_m
1 29 0.4 0.29
2 720 8.9 6.05
3 9 0.1 0.07
4 0 0.0 0.00
5 0 0.0 0.00
6 0 0.0 0.00
7 0 0.0 0.00
8 547 6.8 4.09
9 730 9.1 5.98
10 269 3.3 1.84
11 2887 35.8 21.16
12 89 1.1 0.54
13 7 0.1 0.07
14 2773 34.4 23.55
15 8060 100.0 63.64
'data.frame': 15 obs. of 31 variables:
$ Sl..No. : chr "1" "2" "3" "4" ...
$ Cause : chr "Avalanche" "Exposure to cold" "Cyclone" "Tornado" ...
$ Below.14.years...Male : int 0 6 1 0 0 0 0 76 9 16 ...
$ Below.14.years...Female : int 0 4 0 0 0 0 0 48 8 21 ...
$ Below.14.years...Transgender : int 0 0 0 0 0 0 0 0 0 0 ...
$ Below.14.years...Total : int 0 10 1 0 0 0 0 124 17 37 ...
$ X14.and.Above...Below.18.years...Male : int 1 7 0 0 0 0 0 67 13 4 ...
$ X14.and.Above...Below.18.years...Female : int 0 6 1 0 0 0 0 19 8 4 ...
$ X14.and.Above...Below.18.years...Transgender: int 0 0 0 0 0 0 0 0 0 0 ...
$ X14.and.Above...Below.18.years...Total : int 1 13 1 0 0 0 0 86 21 8 ...
$ X18.and.Above...Below.30.years...Male : int 23 68 0 0 0 0 0 102 59 48 ...
$ X18.and.Above...Below.30.years...Female : int 0 12 0 0 0 0 0 26 16 16 ...
$ X18.and.Above...Below.30.years...Transgender: int 0 0 0 0 0 0 0 0 2 0 ...
$ X18.and.Above...Below.30.years...Total : int 23 80 0 0 0 0 0 128 77 64 ...
$ X30.and.Above...Below.45.years...Male : int 5 187 4 0 0 0 0 76 178 78 ...
$ X30.and.Above...Below.45.years...Female : int 0 21 0 0 0 0 0 14 31 24 ...
$ X30.and.Above...Below.45.years...Transgender: int 0 3 0 0 0 0 0 0 0 1 ...
$ X30.and.Above...Below.45.years...Total : int 5 211 4 0 0 0 0 90 209 103 ...
$ X45.and.Above.Below.60.years...Male : int 0 205 1 0 0 0 0 61 214 30 ...
$ X45.and.Above.Below.60.years...Female : int 0 39 1 0 0 0 0 14 31 11 ...
$ X45.and.Above.Below.60.years...Transgender : int 0 0 0 0 0 0 0 0 5 0 ...
$ X45.and.Above.Below.60.years...Total : int 0 244 2 0 0 0 0 75 250 41 ...
$ X60.years...Above...Male : int 0 132 1 0 0 0 0 27 125 8 ...
$ X60.years...Above...Female : int 0 30 0 0 0 0 0 17 30 8 ...
$ X60.years...Above...Transgender : int 0 0 0 0 0 0 0 0 1 0 ...
$ X60.years...Above...Total : int 0 162 1 0 0 0 0 44 156 16 ...
$ Total...Male : int 29 605 7 0 0 0 0 409 598 184 ...
$ Total...Female : int 0 112 2 0 0 0 0 138 124 84 ...
$ Total...Transgender : int 0 3 0 0 0 0 0 0 8 1 ...
$ Total...Total : int 29 720 9 0 0 0 0 547 730 269 ...
$ Total...Percentage.Share : num 0.4 8.9 0.1 0 0 0 0 6.8 9.1 3.3 ...
---
title: "Assignment2"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
source_code: embed
theme: spacelab
social: menu
---
```{r setup, include=FALSE}
library(flexdashboard)
library(dplyr)
library(ggplot2)
library(lattice)
library(readr)
library(reshape2)
library(DT)
```
## Overview {.tabset}
### summary
```{r}
a=read.csv("/cloud/project/datasets/ADSI.csv")
head(a)
summary(a)
```
### mutate
```{r}
newattr=a %>% mutate(Percentage_of_m = Total...Male / 100)
newattr
```
### structure
```{r}
str(a)
```
## Analysis {.tabset}
### Basic boxplot
```{r}
a$Cause <- as.factor(a$Cause)
a$Sl..No. <- as.factor(a$Sl..No.)
d= a%>% select(Cause,Below.14.years...Female,X14.and.Above...Below.18.years...Female,)
boxplot(d)
```
### Basic Scatterplot
```{r}
plot(d)
```
### Basic Histogram
```{r}
hist(a$Below.14.years...Male)
```
### Boxplot for sliced dataset
```{r}
c= a %>% slice(7:14)
c$Cause <- as.factor(c$Cause)
c$Sl..No. <- as.factor(c$Sl..No.)
boxplot(c)
```
### Boxplot for mutated dataset
```{r}
newattr=a %>% mutate(Percentage_of_m = Total...Male / 100)
boxplot(newattr)
```
## Uni Variant analysis {.tabset}
### Histogram for female below 14
```{r}
hist(c$Below.14.years...Female)
```
### Histogram for Female Population Below 14 Years
```{r}
ggplot(newattr, aes(x = Below.14.years...Female)) +
geom_histogram(color = "black", fill = "pink") +
labs(x = "Below 14 aged females", y = "Frequency") +
ggtitle("Histogram for below 14 years female") +
theme_minimal()
```
### subset of dataset and histogram
```{r}
age<- a %>%
dplyr::select(Cause,
`Below.14.years...Female`,
`X14.and.Above...Below.18.years...Female`,
`X18.and.Above...Below.30.years...Female`,
`X30.and.Above...Below.45.years...Female`,
`X45.and.Above.Below.60.years...Female`,
`X60.years...Above...Female`,
'Total...Female')
#Melt the data into long format for combining attributes
age_groups_long <- melt(age, id.vars = "Cause",
variable.name = "Age_Group",
value.name = "Population")
#Create a combined histogram for the selected attributes (age groups)
ggplot(age_groups_long, aes(x=Population, fill=Age_Group)) +
geom_histogram(binwidth=50, position="identity", alpha=0.5, color="black") +
ggtitle("Combined Histogram for Population Distribution Across Age Groups") +
xlab("Population") +
ylab("Frequency") +
theme_minimal() +
theme(legend.position = "top") +
scale_fill_brewer(palette="Set3")
```
## Bi- variant analysis {.tabset}
### Boxplot for male
```{r}
ggplot(a, aes(y=`Below.14.years...Male`)) +
geom_boxplot(fill="skyblue", color="black") +
ggtitle("Boxplot for Below 14 Years male Population")
```
### boxplot for subset data
```{r}
age_groups <- a %>%
dplyr::select(`X45.and.Above.Below.60.years...Male`, `X45.and.Above.Below.60.years...Female`,
`X45.and.Above.Below.60.years...Total`)
# Melt the data into long format
age_groups_long <- melt(age_groups)
# Create a boxplot for multiple age groups
ggplot(age_groups_long, aes(x=variable, y=value, fill=variable)) +
geom_boxplot() +
ggtitle("Boxplot for Multiple Age Groups") +
xlab("Age Groups") +
ylab("Population") +
theme_minimal()
```
### Boxplot for Total population for each age group
```{r}
age <- newattr %>%
dplyr::select(Cause,
`Total...Male`,
`Total...Female`,
`Total...Transgender`,
`Total...Total`,
`Total...Percentage.Share`,
)
#Melt the data into a long format (convert wide data to long format)
age_groups_long <- melt(age, id.vars = "Cause",
variable.name = "Age_Group",
value.name = "Population")
#Create a boxplot for multiple age groups
ggplot(age_groups_long, aes(x=Age_Group, y=Population, fill=Age_Group)) +
geom_boxplot(outlier.color = "black", outlier.shape = 16) +
ggtitle("Boxplot of Population Distribution Across Age Groups") +
xlab("Age Groups") +
ylab("Population") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) # Tilt x-axis labels for readability
```
## Barplot {.tabset}
### barplot for total death
```{r}
ggplot(a, aes(x = reorder(Cause, `Total...Total`), y = `Total...Total`)) +
geom_bar(stat = "identity", fill = "steelblue") +
coord_flip() +
labs(title = "Total Deaths by Cause", x = "Cause", y = "Total Deaths") +
theme_minimal()
```
### facet by age
```{r}
ggplot(a, aes(x = reorder(Cause, `Total...Total`), y = `Total...Total`)) +
geom_bar(stat = "identity", fill = "steelblue") +
facet_wrap(~ Cause, scales = "free_y") +
coord_flip() +
labs(title = "Total Deaths by Cause (Faceted by Age Group)",
x = "Cause", y = "Total Deaths") +
theme_minimal()
```
### barplot for age and gender
```{r}
ggplot(a, aes(x = reorder(Cause, `Total...Total`))) +
geom_bar(aes(y = `Below.14.years...Male`, fill = "Below 14 Male"), stat = "identity", position = "dodge") +
geom_bar(aes(y = `Below.14.years...Female`, fill = "Below 14 Female"), stat = "identity", position = "dodge") +
geom_bar(aes(y = `X14.and.Above...Below.18.years...Male`, fill = "14-18 Male"), stat = "identity", position = "dodge") +
geom_bar(aes(y = `X14.and.Above...Below.18.years...Female`, fill = "14-18 Female"), stat = "identity", position = "dodge") +
coord_flip() +
labs(title = "Deaths by Cause, Age Group, and Gender",
x = "Cause", y = "Total Deaths") +
theme_minimal() +
scale_fill_manual(values = c("Below 14 Male" = "blue", "Below 14 Female" = "pink",
"14-18 Male" = "darkblue", "14-18 Female" = "lightpink"))
```
## Multi-variant analysis {.tabset}
### scatterplot
```{r}
age_groups <- a %>%
dplyr::select(Cause,
`X45.and.Above.Below.60.years...Female`,
`X45.and.Above.Below.60.years...Total`)
#Create the scatter plot
ggplot(age_groups, aes(x=`X45.and.Above.Below.60.years...Female`, y=`X45.and.Above.Below.60.years...Total`)) +
geom_point(color="pink", size=3) + # Scatter plot points
geom_smooth(method="lm", se=FALSE, color="black") + # Add a trend line (optional)
ggtitle("Scatter Plot of Population: Below 14 Years vs 18 to 30 Years") +
xlab("Below 14 Years Population") +
ylab("18 to 30 Years Population") +
theme_minimal()
```
### scatterplot for male
```{r}
age_groups <- a %>%
dplyr::select(`X45.and.Above.Below.60.years...Male`, `X45.and.Above.Below.60.years...Female`,
`X45.and.Above.Below.60.years...Total`)
# Melt the data into long format
age_groups_long <- melt(age_groups)
# Create a boxplot for multiple age groups
ggplot(age_groups_long, aes(x=variable, y=value, fill=variable)) +
geom_point() +
ggtitle("Boxplot for Multiple Age Groups") +
xlab("Age Groups") +
ylab("Population") +
theme_minimal()
```
### point plot for death by age
```{r}
ggplot(a, aes(x = reorder(Cause, `Total...Female`))) +
geom_point(aes(y = `Below.14.years...Female`, color = "<14"), size = 2) +
geom_point(aes(y = `X14.and.Above...Below.18.years...Female`, color = ">14 & <18"), size = 2) +
geom_point(aes(y = `X18.and.Above...Below.30.years...Female`, color = ">18 & <30"), size = 2) +
geom_point(aes(y = `X30.and.Above...Below.45.years...Female`, color = ">30 & <45"), size = 2) +
geom_point(aes(y = `X45.and.Above.Below.60.years...Female`, color = ">45 & <60"), size = 2) +
geom_point(aes(y = `X60.years...Above...Female`, color = ">60"), size = 2) +
labs(title = " Female Deaths by Age Group (Point Plot)",
x = "Cause", y = "Total Deaths") +
theme_minimal() +
coord_flip()
```
### Barchart
```{r}
age_groups <- a %>%
dplyr::select(Cause,
`Below.14.years...Male`,
`X14.and.Above...Below.18.years...Male`,
`X18.and.Above...Below.30.years...Male`,
`X30.and.Above...Below.45.years...Male`,
`X45.and.Above.Below.60.years...Male`,
`X60.years...Above...Male`,
'Total...Male')
#Melt the data into long format
age_groups_long <- melt(age_groups, id.vars = "Cause",
variable.name = "Age_Group",
value.name = "Population")
#Create the stacked bar chart
ggplot(age_groups_long, aes(x=Cause, y=Population, fill=Age_Group)) +
geom_bar(stat="identity") + # stat="identity" ensures that the y-values represent the height of the bars
ggtitle("Stacked Bar Chart of Population by Cause and Age Group") +
xlab("Cause") +
ylab("Population") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) + # Rotates x-axis labels for readability
scale_fill_brewer(palette="Set3") # Uses a color palette for stacked bars
```