library(tidyverse)
library(grid)
library(dplyr)
library(gganimate)
library(ggplot2)
nt <- read.csv("C:/Users/Admin/Downloads/WHO.csv",header = T)
names(nt) #Quan sát các biến trong dữ liệu
## [1] "Country" "Region"
## [3] "Population" "Under15"
## [5] "Over60" "FertilityRate"
## [7] "LifeExpectancy" "ChildMortality"
## [9] "CellularSubscribers" "LiteracyRate"
## [11] "GNI" "PrimarySchoolEnrollmentMale"
## [13] "PrimarySchoolEnrollmentFemale"
Ta thấy bộ dữ liệu trên nói về các phần xã hội trong mỗi quốc gia trên thế giới bao gồm:
194 quan sát và 13 biến:
“Country” : Quốc gia
“Region” : Khu vực của Quốc gia đó
“Population” : Tổng dân số
“Under15” : Dân số dưới 15 tuổi
“Over60” : Dân số trên 60 tuổi
“FertilityRate” : Tỷ lệ sinh
“LifeExpectancy”: Tuổi thọ
“ChildMortality”: Tử vong ở trẻ em
“CellularSubscribers”: Đăng kí mạng di động
“LiteracyRate”: Tỷ lệ biết đọc viết
“GNI” : Thu nhập quốc dân
“PrimarySchoolEnrollmentMale” : Tiểu học tuyển sinh Nam
“PrimarySchoolEnrollmentFemale”: Tiểu học tuyển sinh Nữ
ggplot(nt,aes(x= Under15,y= FertilityRate)) +
geom_line() +
labs(title = "1.BIỂU ĐỒ TUỔI DƯỚI 15 VÀ TỶ LỆ SINH", x= 'TUỔI DƯỚI 15', y= 'TỶ LỆ SINH')
ggplot(nt,aes(x= Under15,y= LiteracyRate)) +
geom_line() +
labs(title = "2.BIỂU ĐỒ TUỔI DƯỚI 15 VÀ TỶ LỆ BIẾT CHỮ", x= 'TUỔI DƯỚI 15', y= 'TỶ LỆ BIẾT CHỮ')
nt %>% group_by(Region) %>% summarise(FertilityRate) %>%
ggplot(aes(Region,FertilityRate)) +
geom_col(fill='PINK') +
geom_text(aes(label = FertilityRate),Vjust= 1, color = 'WHITE') +
labs(x = 'Khu Vực', y = 'Tỷ Lệ Sinh')
ggplot(nt,aes(x= Under15, y= LiteracyRate)) +
geom_col() +
labs(title = "4.BIỂU ĐỒ TUỔI DƯỚI 15 VÀ TỶ LỆ BIẾT CHỮ", x= 'TUỔI DƯỚI 15', y= 'TỶ LỆ BIẾT CHỮ')
nt2 <- nt %>% filter(Country %in% c('Vietnam','Nepal','Brazil', 'Cambodia', 'Oman'))
nt2 <- nt2 %>% select(Country,Population,LifeExpectancy)
nt2 %>% ggplot(aes(x = LifeExpectancy, y = Population, color = Country)) +
geom_point(size=3) +
labs(title = "5.BIỂU ĐỒ TUỔI THỌ TRONG TỔNG DÂN SỐ CỦA CÁC QUỐC GIA", x= 'Tuổi Thọ', y= 'Tổng dân số', color = 'Quốc gia')
nt1 <- nt %>% filter(Country %in% c('China','Chile','Brazil', 'Cambodia', 'Australia'))
nt1 <- nt1 %>% select(Country,Over60,Under15)
nt1 %>% ggplot(aes(x = Under15, y = Over60, color = Country)) +
geom_point(size=3) +
labs(title = "6.BIỂU ĐỒ TUỔI DÂN DƯỚI 15 VÀ TRÊN 60 CỦA CÁC QUỐC GIA", x= 'DƯỚI 15', y= 'TRÊN 60', color = 'Quốc gia')
nt3 <- nt %>% filter(Country %in% c('China','Colombia','Jordan', 'Angola', 'Argentina'))
nt3 <- nt3 %>% select(Country,LiteracyRate,FertilityRate)
nt3 %>% ggplot(aes(x = FertilityRate, y = LiteracyRate, color = Country)) +
geom_point(size=2) +
labs(title = "7.BIỂU ĐỒ TỶ LỆ SINH VÀ TỶ LỆ BIẾT CHỮ CỦA CÁC QUỐC GIA", x= 'TỶ LỆ SINH', y= 'TỶ LỆ BIẾT CHỮ', color = 'Quốc gia')
nt4 <- nt %>% filter(Country %in% c('China','Colombia','Jordan', 'Angola', 'Argentina'))
nt4 <- nt4 %>% select(Country,Population,ChildMortality)
nt4 %>% ggplot(aes(x = Population, y = ChildMortality, color = Country)) +
geom_point(size=2) +
labs(title = "8.BIỂU ĐỒ TỶ LỆ TỬ VONG Ở TRẺ EM VÀ TỔNG DÂN SỐ CỦA CÁC QUỐC GIA", x= 'TỔNG DÂN SỐ', y= 'TỶ LỆ TRẺ CON TỬ VONG', color = 'Quốc gia')
nt %>% ggplot(aes(x= LifeExpectancy)) +
geom_density(color = "black", fill = 'pink') +
xlim(30,70) +
ylim(0,0.1) +
labs(title = '9.BIỂU ĐỒ MẬT ĐỘ TUỔI THỌ CỦA NGƯỜI DÂN CÁC QUỐC GIA', x = 'Tuổi Thọ',y = 'Mật Độ' )