Dorcas Olanike Agboola
2024-12-10
## Load and Explore the dataset
setwd("C:/Users/USER/Desktop/ICAMMDA/Data Analytics/")
library(readr)
WSP<- read_csv("C:/Users/USER/Desktop/ICAMMDA/Data Analytics/world_standard_population_by_sex.csv")
View(WSP)## AgeGroup Sex WorldStandardPopulation
## Length:36 Length:36 Min. : 500
## Class :character Class :character 1st Qu.: 3000
## Mode :character Mode :character Median : 6000
## Mean : 5556
## 3rd Qu.: 8000
## Max. :12000
library(ggplot2)
ggplot(WSP, aes(WorldStandardPopulation))+
geom_histogram(bins=25,fill="green",col="orange")ggplot(WSP,aes(Sex))+geom_bar(fill= "blue")+
labs(title=" Frequency representation of Sex",x= "Sex", y= "Frequency")ggplot(WSP, aes(Sex, fill = Sex)) +
geom_bar() +
scale_fill_manual(values = c("Male" = "blue", "Female" = "orange"))+
labs(title=" Frequency representation of Sex",x= "Sex", y= "Frequency")ggplot(WSP, aes(Sex,WorldStandardPopulation, color=Sex))+
geom_point(size=3)+scale_fill_manual(values = c("Male" = "royalblue", "Female" = "orange"))+
labs(title=" Scatter Plot representation of Sex",x= "Sex", y= "Frequency")ggplot(WSP, aes(AgeGroup, WorldStandardPopulation, fill = Sex)) +
geom_bar(stat = "identity", position = "dodge") +
scale_fill_manual(values = c("Male" = "blue", "Female" = "orange")) +labs(title=" Barchart representation of AgeGroup and Sex",x= "AgeGroup", y= "Population")+
theme(axis.text.x = element_text(angle = 45, hjust = 1))#WSP$AgeGroup <- factor(WSP$AgeGroup, levels = unique(WSP$AgeGroup))
#View(WSP)
#WSP$AgeGroup <- factor(WSP$AgeGroup, levels = c("0-4", "5-9", "10-14", "15-19", "20-24","25-29","30-34","35-39","40-44","45-49","50-54","55-59","60-64","65-69","70-74","75-79","80-84","85-above"))
ggplot(WSP, aes(AgeGroup, WorldStandardPopulation, fill = Sex)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = c("Male" = "blue", "Female" = "orange")) +
labs(title = "World Standard Population by Age Group and Sex",
x = "Age Group",
y = "World Standard Population",
fill = "Sex") +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5,
hjust = 1))