library(ggplot2)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ lubridate 1.9.3 ✔ tibble 3.2.1
## ✔ purrr 1.0.2 ✔ tidyr 1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
library(sf)
## Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library(rnaturalearth)
library(rnaturalearthdata)
##
## Attaching package: 'rnaturalearthdata'
##
## The following object is masked from 'package:rnaturalearth':
##
## countries110
library(ggcorrplot)
library(ggforce)
library(readxl)
library(gridExtra)
##
## Attaching package: 'gridExtra'
##
## The following object is masked from 'package:dplyr':
##
## combine
library(sf)
library(ggspatial)
library(dplyr)
library(reshape2)
##
## Attaching package: 'reshape2'
##
## The following object is masked from 'package:tidyr':
##
## smiths
data_gizi <- read_xlsx("C:/Users/LENOVO/Downloads/DATA 2022.xlsx")
data_gizi
## # A tibble: 27 × 11
## `Kab/Kota Jawa Barat` `Balita Kurang Gizi (Prevalensi)` `Penimbangan Balita`
## <chr> <dbl> <dbl>
## 1 Kota Cirebon 6.2 89
## 2 Cirebon 5.9 88.5
## 3 Sumedang 3.6 86.8
## 4 Kota Tasikmalaya 5.5 75.9
## 5 Garut 4.3 81.7
## 6 Kota Cimahi 3.1 80.6
## 7 Kota Sukabumi 5 79.2
## 8 Kota Bandung 4.5 58.4
## 9 Tasikmalaya 5.1 82.5
## 10 Kuningan 4.3 89.1
## # ℹ 17 more rows
## # ℹ 8 more variables: `Prevalensi Balita Pendek` <dbl>,
## # `Prevalensi Balita Kurus` <dbl>, `Bayi baru lahir mendapat imd` <dbl>,
## # `Balita diberi asi eksklusif` <dbl>, `Balita mendapat Vitamin A` <dbl>,
## # PHBS <dbl>, `Akses Sanitasi` <dbl>, `Jumlah Penduduk Miskin` <dbl>
Y <- data_gizi$`Balita Kurang Gizi (Prevalensi)`
X1 <- data_gizi$`Penimbangan Balita`
X2 <- data_gizi$`Prevalensi Balita Pendek`
X3 <- data_gizi$`Prevalensi Balita Kurus`
X4 <- data_gizi$`Bayi baru lahir mendapat imd`
X5 <- data_gizi$`Balita diberi asi eksklusif`
X6 <- data_gizi$`Balita mendapat Vitamin A`
X7 <- data_gizi$`PHBS`
X8 <- data_gizi$`Akses Sanitasi`
X9 <- data_gizi$`Jumlah Penduduk Miskin`
data_gizi <-data.frame(cbind(Y,X1,X2,X3,X4,X5,X6,X7,X8,X9))
data_gizi[] <- lapply(data_gizi, as.numeric)
head(data_gizi)
## Y X1 X2 X3 X4 X5 X6 X7 X8 X9
## 1 6.2 89.0 12.8 15.0 87.3 68.0 100.0 74.96 86.7 0.6333617
## 2 5.9 88.5 6.5 8.9 81.9 70.7 98.1 71.07 91.0 4.3792120
## 3 3.6 86.8 8.3 8.4 89.8 81.0 103.2 59.12 98.5 2.3429044
## 4 5.5 75.9 12.7 10.5 86.0 67.6 99.7 43.88 63.8 1.3543788
## 5 4.3 81.7 15.1 10.1 91.1 75.7 96.1 55.09 93.5 5.2489145
## 6 3.1 80.6 9.7 7.6 88.5 78.1 99.8 53.41 83.1 1.2055730
plot_X1 <- ggplot(data_gizi, aes(x = X2, y = Y)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
labs(x = "Pravelensi Balita Pendek", y = "Balita Kurang Gizi")
plot_X2 <- ggplot(data_gizi, aes(x = X3, y = Y)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
labs(x = "Pravelensi Balita Kurus", y = "Balita Kurang Gizi")
plot_X3 <- ggplot(data_gizi, aes(x = X7, y = Y)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
labs(x = "PHBS", y = "Balita Kurang Gizi")
plot_X4 <- ggplot(data_gizi, aes(x = X9, y = Y)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
labs(x = "Penduduk Miskin", y = "Balita Kurang Gizi")
# Menggabungkan scatter plot ke dalam satu layout
grid.arrange(plot_X1, plot_X2, plot_X3, plot_X4, nrow = 2)
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Menurut grafik korelasi di atas bisa kita lihat kalau Pravelensi balita
pendek dan kurus memiliki korelasi yang cukup baik dan bernilai positif.
Sedangkan, peubah PHBS dan Pendusuk miskin memiliki korelasi yang tidak
cukup baik dan bernilai negatif.
data_gizi$Persentase_Kemiskinan_diKota<- ifelse(data_gizi$X9 >= 1, "Banyak Penduduk Miskin", "Tidak Terlalu Banyak Penduduk Miskin")
ggplot(data_gizi, aes(y = Y, x = X9, color = Persentase_Kemiskinan_diKota)) +
geom_point() +
labs(title = "Scatter Plot", x = "Penduduk Miskin", y = "Balita Kurang Gizi") +
theme_classic()
Dapat dilihat di atas jika kota yang memiliki persentase penduduk miskin
yang sedikit belum tentu masyarakatnya tidak mengalami gizi buruk,
justru kota yang persentase kemiskinanya paling rendah memiliki jumlah
balita yang mengalami gizi buruk.
data_gizinumerik <- select_if(data_gizi, is.numeric)
str(data_gizinumerik)
## 'data.frame': 27 obs. of 10 variables:
## $ Y : num 6.2 5.9 3.6 5.5 4.3 3.1 5 4.5 5.1 4.3 ...
## $ X1: num 89 88.5 86.8 75.9 81.7 80.6 79.2 58.4 82.5 89.1 ...
## $ X2: num 12.8 6.5 8.3 12.7 15.1 9.7 4 6.4 14.2 6.6 ...
## $ X3: num 15 8.9 8.4 10.5 10.1 7.6 7.7 8.1 8.9 6.9 ...
## $ X4: num 87.3 81.9 89.8 86 91.1 88.5 88.4 88.5 88.9 74.4 ...
## $ X5: num 68 70.7 81 67.6 75.7 78.1 73.9 75.5 60.7 78.4 ...
## $ X6: num 100 98.1 103.2 99.7 96.1 ...
## $ X7: num 75 71.1 59.1 43.9 55.1 ...
## $ X8: num 86.7 91 98.5 63.8 93.5 83.1 95.5 100 89.7 95.3 ...
## $ X9: num 0.633 4.379 2.343 1.354 5.249 ...
data_melt <- cor(data_gizinumerik[sapply(data_gizinumerik,is.numeric)])
data_melt <- melt(data_melt)
ggplot(data_melt, aes(x = Var1, y = Var2, fill = value)) +
geom_tile() +
labs(title = "Correlation Heatmap",
x = "Variable 1",
y = "Variable 2")
ggplot(data_melt, aes(Var1, Var2, fill = value)) +
geom_tile(color = "white") +
scale_fill_gradient2(low = "blue", mid = "white", high = "red", midpoint = 0, limits = c(-1,1), name="Korelasi") +
labs(title = "Corellogram") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))
data_corrl <- round(cor(data_gizinumerik), 1)
data_corrl <- cor(data_corrl)
ggcorrplot(data_corrl)
ggcorrplot(data_corrl, method = "circle")
Menurut gambar di atas dapat kita lihat bahwa beberapa variabel x
terdapat indikasi multikolinearitas, seperti pada varibael X2 dan X3.
Korelasinya yang cukup besar ini di tandakan dengan warna merah yang
pekat atau hampir menyentuh 1. Oleh karena itu, dapat disimpulkan bahwa
variabel X2 dan X3 saling mempengaruhi.
datats <- read_csv("C:/Users/LENOVO/Downloads/Documents/TSLA.csv")
## Rows: 1259 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (6): Open, High, Low, Close, Adj Close, Volume
## date (1): Date
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
datats
## # A tibble: 1,259 × 7
## Date Open High Low Close `Adj Close` Volume
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2017-09-18 25.4 26.0 25.2 25.7 25.7 107820000
## 2 2017-09-19 25.3 25.5 24.9 25.0 25.0 96778500
## 3 2017-09-20 24.9 25.2 24.7 24.9 24.9 73786500
## 4 2017-09-21 25.0 25.1 24.3 24.4 24.4 69273000
## 5 2017-09-22 24.4 24.7 23.4 23.4 23.4 122391000
## 6 2017-09-25 23.5 23.8 22.9 23.0 23.0 114088500
## 7 2017-09-26 23.4 23.4 22.7 23.0 23.0 107344500
## 8 2017-09-27 23.3 23.4 22.7 22.7 22.7 90904500
## 9 2017-09-28 22.7 22.8 22.4 22.6 22.6 79794000
## 10 2017-09-29 22.8 23.0 22.6 22.7 22.7 76606500
## # ℹ 1,249 more rows
str(datats)
## spc_tbl_ [1,259 × 7] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ Date : Date[1:1259], format: "2017-09-18" "2017-09-19" ...
## $ Open : num [1:1259] 25.4 25.3 24.9 25 24.4 ...
## $ High : num [1:1259] 26 25.5 25.2 25.1 24.7 ...
## $ Low : num [1:1259] 25.2 24.9 24.7 24.3 23.4 ...
## $ Close : num [1:1259] 25.7 25 24.9 24.4 23.4 ...
## $ Adj Close: num [1:1259] 25.7 25 24.9 24.4 23.4 ...
## $ Volume : num [1:1259] 1.08e+08 9.68e+07 7.38e+07 6.93e+07 1.22e+08 ...
## - attr(*, "spec")=
## .. cols(
## .. Date = col_date(format = ""),
## .. Open = col_double(),
## .. High = col_double(),
## .. Low = col_double(),
## .. Close = col_double(),
## .. `Adj Close` = col_double(),
## .. Volume = col_double()
## .. )
## - attr(*, "problems")=<externalptr>
datats <- head(datats, -1)
ggplot(datats, aes(x =Date, y = High)) +
geom_point() +
labs(title = "Scatter Plot of Time Series Data (TSLA)",
x = "Date",
y = "Value (High)")
ggplot(datats, aes(x = Date, y = High)) +
geom_point() +
geom_line() +
labs(title = "Scatter Plot of Time Series Data (TSLA)",
x = "Date",
y = "Value (High)")
ggplot(datats, aes(x = Date, y = High)) +
geom_line() +
labs(title = "Scatter Plot of Time Series Data (TSLA)",
x = "Date",
y = "Value (High)")
datats_high <- datats$High
data.ts <- ts(datats_high)
plot(data.ts, xlab ="Time", ylab = "Data High TSLA", col="red", main = "Plot Data high TSLA")
points(data.ts)
Seluruh gambar di atas menggambarkan pola kenaikan dan penurunan pada
saham perusahaan otomotif Tesla pada rentang tahun 2017-2022. Terlihat
dari grafik jika saham Tesla mengalami tren kenaikan, dapat dilihat
titik puncak level tertinggi saham Tesla terjadi saat akhir tahun 2021
dan terjadi penurunan pada pertengahan tahun 2022.
datats2 <- read_csv("C:/Users/LENOVO/Downloads/Documents/NVDA.csv")
## Rows: 1260 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (6): Open, High, Low, Close, Adj Close, Volume
## date (1): Date
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
datats2
## # A tibble: 1,260 × 7
## Date Open High Low Close `Adj Close` Volume
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2017-06-12 36.5 37.9 35.5 37.5 37.1 169753200
## 2 2017-06-13 38.6 38.7 36.4 37.8 37.4 167250400
## 3 2017-06-14 37.9 38.5 37.1 37.9 37.5 118464000
## 4 2017-06-15 36.7 38.4 36.6 38.1 37.7 96382400
## 5 2017-06-16 38.2 38.7 37.6 37.9 37.5 92496000
## 6 2017-06-19 38.4 39.4 38.3 39.3 38.9 77817600
## 7 2017-06-20 39.8 40.4 39.2 39.3 38.8 109544400
## 8 2017-06-21 39.6 39.9 38.9 39.9 39.4 68265200
## 9 2017-06-22 40.0 40.1 39.3 39.6 39.2 46913200
## 10 2017-06-23 39.7 39.8 38.3 38.5 38.0 108858800
## # ℹ 1,250 more rows
datats <- head(datats, -1)
datats2 <- head(datats2, -1)
# Memplot kedua seri waktu
ggplot() +
geom_line(data = datats, aes(x = Date, y = Open, color = "TSLA")) +
geom_line(data = datats2, aes(x = Date, y = Open, color = "NVDA")) +
labs(title = "Perbandingan Dua Data Time Series (TSLA vs. NVDA)",
x = "Date",
y = "Value",
color = "Series") +
scale_color_manual(values = c("TSLA" = "red", "NVDA" = "green")) +
theme_minimal()
Membadingkan dua saham perusahaan Tesla dan Invidia, masing-masing saham
kedua perusahaan tersebtut mengalami kenaikan pada akhir tahun 2021 dan
keduanya pun sama-sama mengalami trend penurunan pada pertengahan tahun
2022. Secara logika kedua saham mereka tidak bisa dibandingkan karena
memiliki bidang usaha yang berbeda, akan tetapi disini kita dapat
melihat perkembangan saham kedua perusahaan besar didunia.
world <- ne_countries(scale = "medium", returnclass = "sf")
ggplot(data = world) +
geom_sf()
spasial <- read.csv("C:/Users/LENOVO/Downloads/2019.csv")
spasial
## Overall.rank Country.or.region Score GDP.per.capita Social.support
## 1 1 Finland 7.769 1.340 1.587
## 2 2 Denmark 7.600 1.383 1.573
## 3 3 Norway 7.554 1.488 1.582
## 4 4 Iceland 7.494 1.380 1.624
## 5 5 Netherlands 7.488 1.396 1.522
## 6 6 Switzerland 7.480 1.452 1.526
## 7 7 Sweden 7.343 1.387 1.487
## 8 8 New Zealand 7.307 1.303 1.557
## 9 9 Canada 7.278 1.365 1.505
## 10 10 Austria 7.246 1.376 1.475
## 11 11 Australia 7.228 1.372 1.548
## 12 12 Costa Rica 7.167 1.034 1.441
## 13 13 Israel 7.139 1.276 1.455
## 14 14 Luxembourg 7.090 1.609 1.479
## 15 15 United Kingdom 7.054 1.333 1.538
## 16 16 Ireland 7.021 1.499 1.553
## 17 17 Germany 6.985 1.373 1.454
## 18 18 Belgium 6.923 1.356 1.504
## 19 19 United States 6.892 1.433 1.457
## 20 20 Czech Republic 6.852 1.269 1.487
## 21 21 United Arab Emirates 6.825 1.503 1.310
## 22 22 Malta 6.726 1.300 1.520
## 23 23 Mexico 6.595 1.070 1.323
## 24 24 France 6.592 1.324 1.472
## 25 25 Taiwan 6.446 1.368 1.430
## 26 26 Chile 6.444 1.159 1.369
## 27 27 Guatemala 6.436 0.800 1.269
## 28 28 Saudi Arabia 6.375 1.403 1.357
## 29 29 Qatar 6.374 1.684 1.313
## 30 30 Spain 6.354 1.286 1.484
## 31 31 Panama 6.321 1.149 1.442
## 32 32 Brazil 6.300 1.004 1.439
## 33 33 Uruguay 6.293 1.124 1.465
## 34 34 Singapore 6.262 1.572 1.463
## 35 35 El Salvador 6.253 0.794 1.242
## 36 36 Italy 6.223 1.294 1.488
## 37 37 Bahrain 6.199 1.362 1.368
## 38 38 Slovakia 6.198 1.246 1.504
## 39 39 Trinidad & Tobago 6.192 1.231 1.477
## 40 40 Poland 6.182 1.206 1.438
## 41 41 Uzbekistan 6.174 0.745 1.529
## 42 42 Lithuania 6.149 1.238 1.515
## 43 43 Colombia 6.125 0.985 1.410
## 44 44 Slovenia 6.118 1.258 1.523
## 45 45 Nicaragua 6.105 0.694 1.325
## 46 46 Kosovo 6.100 0.882 1.232
## 47 47 Argentina 6.086 1.092 1.432
## 48 48 Romania 6.070 1.162 1.232
## 49 49 Cyprus 6.046 1.263 1.223
## 50 50 Ecuador 6.028 0.912 1.312
## 51 51 Kuwait 6.021 1.500 1.319
## 52 52 Thailand 6.008 1.050 1.409
## 53 53 Latvia 5.940 1.187 1.465
## 54 54 South Korea 5.895 1.301 1.219
## 55 55 Estonia 5.893 1.237 1.528
## 56 56 Jamaica 5.890 0.831 1.478
## 57 57 Mauritius 5.888 1.120 1.402
## 58 58 Japan 5.886 1.327 1.419
## 59 59 Honduras 5.860 0.642 1.236
## 60 60 Kazakhstan 5.809 1.173 1.508
## 61 61 Bolivia 5.779 0.776 1.209
## 62 62 Hungary 5.758 1.201 1.410
## 63 63 Paraguay 5.743 0.855 1.475
## 64 64 Northern Cyprus 5.718 1.263 1.252
## 65 65 Peru 5.697 0.960 1.274
## 66 66 Portugal 5.693 1.221 1.431
## 67 67 Pakistan 5.653 0.677 0.886
## 68 68 Russia 5.648 1.183 1.452
## 69 69 Philippines 5.631 0.807 1.293
## 70 70 Serbia 5.603 1.004 1.383
## 71 71 Moldova 5.529 0.685 1.328
## 72 72 Libya 5.525 1.044 1.303
## 73 73 Montenegro 5.523 1.051 1.361
## 74 74 Tajikistan 5.467 0.493 1.098
## 75 75 Croatia 5.432 1.155 1.266
## 76 76 Hong Kong 5.430 1.438 1.277
## 77 77 Dominican Republic 5.425 1.015 1.401
## 78 78 Bosnia and Herzegovina 5.386 0.945 1.212
## 79 79 Turkey 5.373 1.183 1.360
## 80 80 Malaysia 5.339 1.221 1.171
## 81 81 Belarus 5.323 1.067 1.465
## 82 82 Greece 5.287 1.181 1.156
## 83 83 Mongolia 5.285 0.948 1.531
## 84 84 North Macedonia 5.274 0.983 1.294
## 85 85 Nigeria 5.265 0.696 1.111
## 86 86 Kyrgyzstan 5.261 0.551 1.438
## 87 87 Turkmenistan 5.247 1.052 1.538
## 88 88 Algeria 5.211 1.002 1.160
## 89 89 Morocco 5.208 0.801 0.782
## 90 90 Azerbaijan 5.208 1.043 1.147
## 91 91 Lebanon 5.197 0.987 1.224
## 92 92 Indonesia 5.192 0.931 1.203
## 93 93 China 5.191 1.029 1.125
## 94 94 Vietnam 5.175 0.741 1.346
## 95 95 Bhutan 5.082 0.813 1.321
## 96 96 Cameroon 5.044 0.549 0.910
## 97 97 Bulgaria 5.011 1.092 1.513
## 98 98 Ghana 4.996 0.611 0.868
## 99 99 Ivory Coast 4.944 0.569 0.808
## 100 100 Nepal 4.913 0.446 1.226
## 101 101 Jordan 4.906 0.837 1.225
## 102 102 Benin 4.883 0.393 0.437
## 103 103 Congo (Brazzaville) 4.812 0.673 0.799
## 104 104 Gabon 4.799 1.057 1.183
## 105 105 Laos 4.796 0.764 1.030
## 106 106 South Africa 4.722 0.960 1.351
## 107 107 Albania 4.719 0.947 0.848
## 108 108 Venezuela 4.707 0.960 1.427
## 109 109 Cambodia 4.700 0.574 1.122
## 110 110 Palestinian Territories 4.696 0.657 1.247
## 111 111 Senegal 4.681 0.450 1.134
## 112 112 Somalia 4.668 0.000 0.698
## 113 113 Namibia 4.639 0.879 1.313
## 114 114 Niger 4.628 0.138 0.774
## 115 115 Burkina Faso 4.587 0.331 1.056
## 116 116 Armenia 4.559 0.850 1.055
## 117 117 Iran 4.548 1.100 0.842
## 118 118 Guinea 4.534 0.380 0.829
## 119 119 Georgia 4.519 0.886 0.666
## 120 120 Gambia 4.516 0.308 0.939
## 121 121 Kenya 4.509 0.512 0.983
## 122 122 Mauritania 4.490 0.570 1.167
## 123 123 Mozambique 4.466 0.204 0.986
## 124 124 Tunisia 4.461 0.921 1.000
## 125 125 Bangladesh 4.456 0.562 0.928
## 126 126 Iraq 4.437 1.043 0.980
## 127 127 Congo (Kinshasa) 4.418 0.094 1.125
## 128 128 Mali 4.390 0.385 1.105
## 129 129 Sierra Leone 4.374 0.268 0.841
## 130 130 Sri Lanka 4.366 0.949 1.265
## 131 131 Myanmar 4.360 0.710 1.181
## 132 132 Chad 4.350 0.350 0.766
## 133 133 Ukraine 4.332 0.820 1.390
## 134 134 Ethiopia 4.286 0.336 1.033
## 135 135 Swaziland 4.212 0.811 1.149
## 136 136 Uganda 4.189 0.332 1.069
## 137 137 Egypt 4.166 0.913 1.039
## 138 138 Zambia 4.107 0.578 1.058
## 139 139 Togo 4.085 0.275 0.572
## 140 140 India 4.015 0.755 0.765
## 141 141 Liberia 3.975 0.073 0.922
## 142 142 Comoros 3.973 0.274 0.757
## 143 143 Madagascar 3.933 0.274 0.916
## 144 144 Lesotho 3.802 0.489 1.169
## 145 145 Burundi 3.775 0.046 0.447
## 146 146 Zimbabwe 3.663 0.366 1.114
## 147 147 Haiti 3.597 0.323 0.688
## 148 148 Botswana 3.488 1.041 1.145
## 149 149 Syria 3.462 0.619 0.378
## 150 150 Malawi 3.410 0.191 0.560
## 151 151 Yemen 3.380 0.287 1.163
## 152 152 Rwanda 3.334 0.359 0.711
## 153 153 Tanzania 3.231 0.476 0.885
## 154 154 Afghanistan 3.203 0.350 0.517
## 155 155 Central African Republic 3.083 0.026 0.000
## 156 156 South Sudan 2.853 0.306 0.575
## Healthy.life.expectancy Freedom.to.make.life.choices Generosity
## 1 0.986 0.596 0.153
## 2 0.996 0.592 0.252
## 3 1.028 0.603 0.271
## 4 1.026 0.591 0.354
## 5 0.999 0.557 0.322
## 6 1.052 0.572 0.263
## 7 1.009 0.574 0.267
## 8 1.026 0.585 0.330
## 9 1.039 0.584 0.285
## 10 1.016 0.532 0.244
## 11 1.036 0.557 0.332
## 12 0.963 0.558 0.144
## 13 1.029 0.371 0.261
## 14 1.012 0.526 0.194
## 15 0.996 0.450 0.348
## 16 0.999 0.516 0.298
## 17 0.987 0.495 0.261
## 18 0.986 0.473 0.160
## 19 0.874 0.454 0.280
## 20 0.920 0.457 0.046
## 21 0.825 0.598 0.262
## 22 0.999 0.564 0.375
## 23 0.861 0.433 0.074
## 24 1.045 0.436 0.111
## 25 0.914 0.351 0.242
## 26 0.920 0.357 0.187
## 27 0.746 0.535 0.175
## 28 0.795 0.439 0.080
## 29 0.871 0.555 0.220
## 30 1.062 0.362 0.153
## 31 0.910 0.516 0.109
## 32 0.802 0.390 0.099
## 33 0.891 0.523 0.127
## 34 1.141 0.556 0.271
## 35 0.789 0.430 0.093
## 36 1.039 0.231 0.158
## 37 0.871 0.536 0.255
## 38 0.881 0.334 0.121
## 39 0.713 0.489 0.185
## 40 0.884 0.483 0.117
## 41 0.756 0.631 0.322
## 42 0.818 0.291 0.043
## 43 0.841 0.470 0.099
## 44 0.953 0.564 0.144
## 45 0.835 0.435 0.200
## 46 0.758 0.489 0.262
## 47 0.881 0.471 0.066
## 48 0.825 0.462 0.083
## 49 1.042 0.406 0.190
## 50 0.868 0.498 0.126
## 51 0.808 0.493 0.142
## 52 0.828 0.557 0.359
## 53 0.812 0.264 0.075
## 54 1.036 0.159 0.175
## 55 0.874 0.495 0.103
## 56 0.831 0.490 0.107
## 57 0.798 0.498 0.215
## 58 1.088 0.445 0.069
## 59 0.828 0.507 0.246
## 60 0.729 0.410 0.146
## 61 0.706 0.511 0.137
## 62 0.828 0.199 0.081
## 63 0.777 0.514 0.184
## 64 1.042 0.417 0.191
## 65 0.854 0.455 0.083
## 66 0.999 0.508 0.047
## 67 0.535 0.313 0.220
## 68 0.726 0.334 0.082
## 69 0.657 0.558 0.117
## 70 0.854 0.282 0.137
## 71 0.739 0.245 0.181
## 72 0.673 0.416 0.133
## 73 0.871 0.197 0.142
## 74 0.718 0.389 0.230
## 75 0.914 0.296 0.119
## 76 1.122 0.440 0.258
## 77 0.779 0.497 0.113
## 78 0.845 0.212 0.263
## 79 0.808 0.195 0.083
## 80 0.828 0.508 0.260
## 81 0.789 0.235 0.094
## 82 0.999 0.067 0.000
## 83 0.667 0.317 0.235
## 84 0.838 0.345 0.185
## 85 0.245 0.426 0.215
## 86 0.723 0.508 0.300
## 87 0.657 0.394 0.244
## 88 0.785 0.086 0.073
## 89 0.782 0.418 0.036
## 90 0.769 0.351 0.035
## 91 0.815 0.216 0.166
## 92 0.660 0.491 0.498
## 93 0.893 0.521 0.058
## 94 0.851 0.543 0.147
## 95 0.604 0.457 0.370
## 96 0.331 0.381 0.187
## 97 0.815 0.311 0.081
## 98 0.486 0.381 0.245
## 99 0.232 0.352 0.154
## 100 0.677 0.439 0.285
## 101 0.815 0.383 0.110
## 102 0.397 0.349 0.175
## 103 0.508 0.372 0.105
## 104 0.571 0.295 0.043
## 105 0.551 0.547 0.266
## 106 0.469 0.389 0.130
## 107 0.874 0.383 0.178
## 108 0.805 0.154 0.064
## 109 0.637 0.609 0.232
## 110 0.672 0.225 0.103
## 111 0.571 0.292 0.153
## 112 0.268 0.559 0.243
## 113 0.477 0.401 0.070
## 114 0.366 0.318 0.188
## 115 0.380 0.255 0.177
## 116 0.815 0.283 0.095
## 117 0.785 0.305 0.270
## 118 0.375 0.332 0.207
## 119 0.752 0.346 0.043
## 120 0.428 0.382 0.269
## 121 0.581 0.431 0.372
## 122 0.489 0.066 0.106
## 123 0.390 0.494 0.197
## 124 0.815 0.167 0.059
## 125 0.723 0.527 0.166
## 126 0.574 0.241 0.148
## 127 0.357 0.269 0.212
## 128 0.308 0.327 0.153
## 129 0.242 0.309 0.252
## 130 0.831 0.470 0.244
## 131 0.555 0.525 0.566
## 132 0.192 0.174 0.198
## 133 0.739 0.178 0.187
## 134 0.532 0.344 0.209
## 135 0.000 0.313 0.074
## 136 0.443 0.356 0.252
## 137 0.644 0.241 0.076
## 138 0.426 0.431 0.247
## 139 0.410 0.293 0.177
## 140 0.588 0.498 0.200
## 141 0.443 0.370 0.233
## 142 0.505 0.142 0.275
## 143 0.555 0.148 0.169
## 144 0.168 0.359 0.107
## 145 0.380 0.220 0.176
## 146 0.433 0.361 0.151
## 147 0.449 0.026 0.419
## 148 0.538 0.455 0.025
## 149 0.440 0.013 0.331
## 150 0.495 0.443 0.218
## 151 0.463 0.143 0.108
## 152 0.614 0.555 0.217
## 153 0.499 0.417 0.276
## 154 0.361 0.000 0.158
## 155 0.105 0.225 0.235
## 156 0.295 0.010 0.202
## Perceptions.of.corruption
## 1 0.393
## 2 0.410
## 3 0.341
## 4 0.118
## 5 0.298
## 6 0.343
## 7 0.373
## 8 0.380
## 9 0.308
## 10 0.226
## 11 0.290
## 12 0.093
## 13 0.082
## 14 0.316
## 15 0.278
## 16 0.310
## 17 0.265
## 18 0.210
## 19 0.128
## 20 0.036
## 21 0.182
## 22 0.151
## 23 0.073
## 24 0.183
## 25 0.097
## 26 0.056
## 27 0.078
## 28 0.132
## 29 0.167
## 30 0.079
## 31 0.054
## 32 0.086
## 33 0.150
## 34 0.453
## 35 0.074
## 36 0.030
## 37 0.110
## 38 0.014
## 39 0.016
## 40 0.050
## 41 0.240
## 42 0.042
## 43 0.034
## 44 0.057
## 45 0.127
## 46 0.006
## 47 0.050
## 48 0.005
## 49 0.041
## 50 0.087
## 51 0.097
## 52 0.028
## 53 0.064
## 54 0.056
## 55 0.161
## 56 0.028
## 57 0.060
## 58 0.140
## 59 0.078
## 60 0.096
## 61 0.064
## 62 0.020
## 63 0.080
## 64 0.162
## 65 0.027
## 66 0.025
## 67 0.098
## 68 0.031
## 69 0.107
## 70 0.039
## 71 0.000
## 72 0.152
## 73 0.080
## 74 0.144
## 75 0.022
## 76 0.287
## 77 0.101
## 78 0.006
## 79 0.106
## 80 0.024
## 81 0.142
## 82 0.034
## 83 0.038
## 84 0.034
## 85 0.041
## 86 0.023
## 87 0.028
## 88 0.114
## 89 0.076
## 90 0.182
## 91 0.027
## 92 0.028
## 93 0.100
## 94 0.073
## 95 0.167
## 96 0.037
## 97 0.004
## 98 0.040
## 99 0.090
## 100 0.089
## 101 0.130
## 102 0.082
## 103 0.093
## 104 0.055
## 105 0.164
## 106 0.055
## 107 0.027
## 108 0.047
## 109 0.062
## 110 0.066
## 111 0.072
## 112 0.270
## 113 0.056
## 114 0.102
## 115 0.113
## 116 0.064
## 117 0.125
## 118 0.086
## 119 0.164
## 120 0.167
## 121 0.053
## 122 0.088
## 123 0.138
## 124 0.055
## 125 0.143
## 126 0.089
## 127 0.053
## 128 0.052
## 129 0.045
## 130 0.047
## 131 0.172
## 132 0.078
## 133 0.010
## 134 0.100
## 135 0.135
## 136 0.060
## 137 0.067
## 138 0.087
## 139 0.085
## 140 0.085
## 141 0.033
## 142 0.078
## 143 0.041
## 144 0.093
## 145 0.180
## 146 0.089
## 147 0.110
## 148 0.100
## 149 0.141
## 150 0.089
## 151 0.077
## 152 0.411
## 153 0.147
## 154 0.025
## 155 0.035
## 156 0.091
world_map <- map_data("world")
colnames(spasial)[colnames(spasial) == "Country.Territory"] <- "region"
merged_data <- left_join(world_map, spasial, by = c("region" = "Country.or.region"))
ggplot(merged_data, aes(x = long, y = lat, group = group, fill = GDP.per.capita)) +
geom_polygon(color = "black") +
scale_fill_gradient(name = "GDP perCapita (2019)", low = "green", high = "red", guide = "legend") +
theme_void() +
labs(title = "GDP per capita 2019")
Map Chart di atas memvisulisasikan negara dengan GDP per Capita 2019. Warna orange disini menunjukan jika GDP per Capita disuatu negara itu sangat besar dari negara lain, Kuning menunjukan GDP yang lumayan besar dan warna hijau menunjukan GDP per Capita sangat rendah. Serta, negara yang diwarnai abu-abu menunjukan tidak ada datanya atau data tidak terdeteksi.