Kết nối dữ liệu

library(utf8)
library(showtext)
## Warning: package 'showtext' was built under R version 4.0.3
## Loading required package: sysfonts
## Warning: package 'sysfonts' was built under R version 4.0.3
## Loading required package: showtextdb
## Warning: package 'showtextdb' was built under R version 4.0.3
showtext_auto()

font_add_google("Roboto Slab","Ro1")

setwd("d:/DATA2021/ThuySan.VECM")
library(readxl)
dulieu <-read_excel("dothive.xlsx")
dulieu<-data.frame(dulieu)
head(dulieu)
##   NHOM      GDP   FGDP       gGDP ggdp  FEX   EX        gEX  gex
## 1 2000 1115.339 14.906 0.01336455  1.3 1.48 14.5 0.10206897 10.2
## 2 2001 1192.240 17.904 0.01501711  1.5 1.82 15.0 0.12133333 12.1
## 3 2002 1276.656 20.340 0.01593225  1.6 2.02 16.7 0.12095808 12.1
## 4 2003 1370.375 24.125 0.01760467  1.8 2.20 20.1 0.10945274 10.9
## 5 2004 1477.123 27.474 0.01859967  1.9 2.41 26.5 0.09094340  9.1
## 6 2005 1588.646 32.947 0.02073904  2.1 2.73 32.4 0.08425926  8.4

Đồ thị về GDP so sánh

library(ggplot2)

ggplot (data=dulieu) + 
  theme_bw() + 
  theme(text = element_text(family = "Ro1", size=50)) +
  geom_line(aes(x=NHOM,y=GDP), color="red", size=1) + geom_point(aes(x=NHOM,y=GDP), color="red",size=2) +
  geom_line(aes(x=NHOM,y=FGDP), color="blue", size=1) + geom_point(aes(x=NHOM,y=FGDP), color="blue",size=2 , shape=17) + 
                       labs(title="Biểu đồ GDP qua các năm",
                            subtitle = "(2000-2019)",
                            x="Năm",
                            y="Tỷ VND")+
  
  geom_point(aes(x=2000,y=3500),color="red",size=5) + geom_text(aes(x=2000,y=3500, fontface=2),color="red",size=20,label="Giá trị GDP toàn quốc qua các năm", hjust=-0.05, family="Ro1") +
  geom_point(aes(x=2000,y=3000),color="blue",size=5, shape=17) + geom_text(aes(x=2000,y=3000),color="blue",size=20,label="Giá trị GDP ngành thuỷ sản", hjust=-0.045) +

  ggsave("gdpss.png",dpi = 500, width=16,height=9, units = "cm")

Đồ thị xuất khẩu so sánh

ggplot (data=dulieu) + 
  theme_bw() +
  theme(text = element_text(family = "Ro1", size=50)) +
  geom_line(aes(x=NHOM,y=EX), color="red", size=1) + geom_point(aes(x=NHOM,y=EX), color="red",size=2) +
  geom_line(aes(x=NHOM,y=FEX), color="blue", size=1) + geom_point(aes(x=NHOM,y=FEX), color="blue",size=2 , shape=17) + 
                       labs(title="Biểu đồ giá trị xuất khẩu qua các năm",
                            subtitle = "(2000-2019)",
                            x="Năm",
                            y="Tỷ VND" )+
  
  geom_point(aes(x=2000,y=250),color="red",size=5) + geom_text(aes(x=2000,y=250),color="red",size=25,label="Giá trị xuất khẩu toàn quốc qua các năm", hjust=-0.05) +
  geom_point(aes(x=2000,y=200),color="blue",size=5, shape=17) + geom_text(aes(x=2000,y=200),color="blue",size=25,label="Giá trị xuất khẩu  ngành thuỷ sản", hjust=-0.045) +
  
   ggsave("xkss.png", dpi = 500, width=16,height=9, units = "cm")

Đồ thị phần trăm GDP qua các năm

ggplot(data=dulieu)+
  geom_point(aes(x=NHOM,y=ggdp), color="#602C18" , size=8)+
  geom_text(aes(x=NHOM,y=ggdp,label=ggdp), size=2.5,color="white", fontface=2)+
  geom_segment(aes(x=NHOM,xend=NHOM,y=0,yend=ggdp ), color="#bfaaa2", linetype=3, size=0.5)+
  theme_bw()+
  labs(title="Biểu đồ tỷ trọng GDP của ngành thuỷ sản",
                            subtitle = "(2000-2019)",
                            x="Năm",
                            y="Tỷ trọng (%)") +
  ggsave("tilegdp.png", dpi = 500, width=16,height=9, units = "cm")

Đồ thị phần trăm xuất khẩu thuỷ sản

ggplot(data=dulieu)+
  geom_point(aes(x=NHOM,y=gex), color="#0016B8" , size=8)+
  geom_text(aes(x=NHOM,y=gex,label=gex), size=2.5,color="white", fontface=2)+
  geom_segment(aes(x=NHOM,xend=NHOM,y=0,yend=gex ), color="#5C6FFE", linetype=3, size=0.5)+
  theme_bw()+
  labs(title="Biểu đồ tỷ trọng kim ngạch xuất khẩu thuỷ sản",
                            subtitle = "(2000-2019)",
                            x="Năm",
                            y="Tỷ trọng (%)") +
  ggsave("tileEX.png", dpi = 500, width=16,height=9, units = "cm")