G1401221101_IRSYAD PARAMA DWIPUTRA

Buat data frame yang berisi peubah-peubah sebagai berikut:

data_negara <- data.frame(
  Rank = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20),
  Country = c("Japan", "Taiwan", "Singapore", "Hong Kong", "China", "South Korea", "Belarus", "Finland", "Liechtenstein", "Germany", "Netherlands", "Estonia", "Luxembourg", "Macao", "Cambodia", "Canada", "Australia", "Hungary", "Switzerland", "United Kingdom"),
  Region = c("Asia", "Asia", "Asia", "Asia", "Asia", "Asia", "Europe", "Europe", "Europe", "Europe", "Europe", "Europe", "Europe", "Asia", "Asia", "North America", "Oceania", "Europe", "Europe", "Europe"),
  HDI = c(0.99, 0.96, 0.97, 0.94, 0.96, 0.98, 1.00, 1.00, 1.00, 0.99, 0.99, 1.00, 1.00, 0.97, 0.78, 0.99, 0.99, 0.99, 0.99, 0.99),
  Corruption_Index = c(29, NA, 0, 1, 8, 0, 2, 5, 0, 111, 22, 0, 2, 0, 0, 28, 12, 13, 27, 137),
  Life_Expectancy = c(0.925, NA, 0.939, 0.952, 0.768, 0.925, 0.808, 0.940, 0.935, 0.942, 0.941, 0.890, 0.930, NA, 0.593, 0.936, 0.951, 0.846, 0.962, 0.929),
  Education_Index = c(13.4, NA, 11.9, 12.2, 7.6, 12.5, 12.1, 12.9, 12.5, 14.1, 12.6, 13.5, 13.0, NA, 5.1, 13.8, 12.7, 12.2, 13.9, 13.4),
  GDP_Per_Capita = c(42274, 10143543, 90919, 62607, 17504, 44501, 18849, 49452, 146830, 54534, 55979, 38048, 84649, NA, 4079, 46808, 49238, 32789, 66933, 45225),
  Population = c(123294513, 10143543, 6014723, 7491609, 1425671352, 51784059, 9498238, 5545475, 39315, 83294633, 17618299, 1322766, 654768, 704150, 16944826, 38781292, 26439112, 10156239, 8796669, 67736802)
)

data_tambahan <- data.frame(
  Rank = c(21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41),
  Country = c("North Korea", "Slovenia", "New Zealand", "Austria", "Iceland", "Denmark", "Belgium", "United States", "Norway", "Sweden", "France", "Poland", "Slovakia", "Russia", "Lithuania", "Croatia", "Andorra", "Ireland", "Czech Republic", "Latvia", "Italy"),
  HDI = c(98.82, 98.60, 98.57, 98.38, 98.26, 97.83, 97.49, 97.43, 97.13, 97.00, 96.69, 96.35, 96.32, 96.29, 95.89, 95.75, 95.20, 95.13, 94.92, 94.79, 94.23),
  Region = c("Asia", "Europe", "Oceania", "Europe", "Europe", "Europe", "Europe", "North America", "Europe", "Europe", "Europe", "Europe", "Europe", "Europe/Asia", "Europe", "Europe", "Europe", "Europe", "Europe", "Europe", "Europe"),
  Corruption_Index = c(0, 1, 3, 22, 1, 13, 11, 400, 13, 32, 71, 19, 0, 0, 3, 2, 0, 11, 6, 1, 21),
  Life_Expectancy = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
  Education_Index = c(NA, 0.918, 0.937, 0.916, 0.959, 0.948, 0.937, 0.921, 0.961, 0.947, 0.903, 0.876, 0.848, 0.822, 0.875, 0.858, 0.858, 0.945, 0.889, 0.863, 0.895),
  GDP_Per_Capita = c(NA, 39746, 44057, 53619, 55782, 60365, 52293, 64765, 64660, 54489, 45937, 33034, 30690, 27166, 37931, 30132, 51167, 76169, 38745, 32803, 42840),
  Population = c(26160822, 2119675, 5228100, 8958961, 375319, 5910913, 11686140, 339996564, 5474360, 10612086, 64756584, 41026068, 5795199, 144444359, 2718352, 4008617, 76965, 5056935, 10495295, 1830212, 58870763)
)


data_negara <- rbind(data_negara, data_tambahan)

Tampilkan data yang sudah dimasukkan di dataframe dan ditampilkan di dalam bentuk tabel.

print(data_negara)
##    Rank        Country        Region   HDI Corruption_Index Life_Expectancy
## 1     1          Japan          Asia  0.99               29           0.925
## 2     2         Taiwan          Asia  0.96               NA              NA
## 3     3      Singapore          Asia  0.97                0           0.939
## 4     4      Hong Kong          Asia  0.94                1           0.952
## 5     5          China          Asia  0.96                8           0.768
## 6     6    South Korea          Asia  0.98                0           0.925
## 7     7        Belarus        Europe  1.00                2           0.808
## 8     8        Finland        Europe  1.00                5           0.940
## 9     9  Liechtenstein        Europe  1.00                0           0.935
## 10   10        Germany        Europe  0.99              111           0.942
## 11   11    Netherlands        Europe  0.99               22           0.941
## 12   12        Estonia        Europe  1.00                0           0.890
## 13   13     Luxembourg        Europe  1.00                2           0.930
## 14   14          Macao          Asia  0.97                0              NA
## 15   15       Cambodia          Asia  0.78                0           0.593
## 16   16         Canada North America  0.99               28           0.936
## 17   17      Australia       Oceania  0.99               12           0.951
## 18   18        Hungary        Europe  0.99               13           0.846
## 19   19    Switzerland        Europe  0.99               27           0.962
## 20   20 United Kingdom        Europe  0.99              137           0.929
## 21   21    North Korea          Asia 98.82                0              NA
## 22   22       Slovenia        Europe 98.60                1              NA
## 23   23    New Zealand       Oceania 98.57                3              NA
## 24   24        Austria        Europe 98.38               22              NA
## 25   25        Iceland        Europe 98.26                1              NA
## 26   26        Denmark        Europe 97.83               13              NA
## 27   27        Belgium        Europe 97.49               11              NA
## 28   28  United States North America 97.43              400              NA
## 29   29         Norway        Europe 97.13               13              NA
## 30   30         Sweden        Europe 97.00               32              NA
## 31   31         France        Europe 96.69               71              NA
## 32   32         Poland        Europe 96.35               19              NA
## 33   33       Slovakia        Europe 96.32                0              NA
## 34   34         Russia   Europe/Asia 96.29                0              NA
## 35   35      Lithuania        Europe 95.89                3              NA
## 36   36        Croatia        Europe 95.75                2              NA
## 37   37        Andorra        Europe 95.20                0              NA
## 38   38        Ireland        Europe 95.13               11              NA
## 39   39 Czech Republic        Europe 94.92                6              NA
## 40   40         Latvia        Europe 94.79                1              NA
## 41   41          Italy        Europe 94.23               21              NA
##    Education_Index GDP_Per_Capita Population
## 1           13.400          42274  123294513
## 2               NA       10143543   10143543
## 3           11.900          90919    6014723
## 4           12.200          62607    7491609
## 5            7.600          17504 1425671352
## 6           12.500          44501   51784059
## 7           12.100          18849    9498238
## 8           12.900          49452    5545475
## 9           12.500         146830      39315
## 10          14.100          54534   83294633
## 11          12.600          55979   17618299
## 12          13.500          38048    1322766
## 13          13.000          84649     654768
## 14              NA             NA     704150
## 15           5.100           4079   16944826
## 16          13.800          46808   38781292
## 17          12.700          49238   26439112
## 18          12.200          32789   10156239
## 19          13.900          66933    8796669
## 20          13.400          45225   67736802
## 21              NA             NA   26160822
## 22           0.918          39746    2119675
## 23           0.937          44057    5228100
## 24           0.916          53619    8958961
## 25           0.959          55782     375319
## 26           0.948          60365    5910913
## 27           0.937          52293   11686140
## 28           0.921          64765  339996564
## 29           0.961          64660    5474360
## 30           0.947          54489   10612086
## 31           0.903          45937   64756584
## 32           0.876          33034   41026068
## 33           0.848          30690    5795199
## 34           0.822          27166  144444359
## 35           0.875          37931    2718352
## 36           0.858          30132    4008617
## 37           0.858          51167      76965
## 38           0.945          76169    5056935
## 39           0.889          38745   10495295
## 40           0.863          32803    1830212
## 41           0.895          42840   58870763

Ubah data menjadi berbagai macam grafik-grafik

#BUAT GRAFIK BOXPLOT

par(mfrow = c(2, 3)) 
boxplot(data_negara$Rank, main = "Boxplot Rank", ylab = "Rank", col = "skyblue")
boxplot(data_negara$HDI, main = "Boxplot HDI", ylab = "HDI", col = "lightgreen")
boxplot(data_negara$Corruption_Index, main = "Boxplot Corruption Index", ylab = "Corruption Index", col = "lightcoral")
boxplot(data_negara$Life_Expectancy, main = "Boxplot Life Expectancy", ylab = "Life Expectancy", col = "lightgoldenrod")
boxplot(data_negara$Education_Index, main = "Boxplot Education Index", ylab = "Education Index", col = "lightsteelblue")
boxplot(data_negara$GDP_Per_Capita, main = "Boxplot GDP Per Capita", ylab = "GDP Per Capita", col = "lightsalmon")

par(mfrow = c(1, 1))

# BUAT GRAFIK HISTOGRAM

par(mfrow = c(2, 3))
hist(data_negara$Rank, main = "Histogram Rank", xlab = "Rank", col = "skyblue")
hist(data_negara$HDI, main = "Histogram HDI", xlab = "HDI", col = "lightgreen")
hist(data_negara$Corruption_Index, main = "Histogram Corruption Index", xlab = "Corruption Index", col = "lightcoral")
hist(data_negara$Life_Expectancy, main = "Histogram Life Expectancy", xlab = "Life Expectancy", col = "lightgoldenrod")
hist(data_negara$Education_Index, main = "Histogram Education Index", xlab = "Education Index", col = "lightsteelblue")
hist(data_negara$GDP_Per_Capita, main = "Histogram GDP Per Capita", xlab = "GDP Per Capita", col = "lightsalmon")

par(mfrow = c(1, 1))

#BUAT GRAFIK SCATTERPLOT 

plot(data_negara$Corruption_Index, data_negara$Education_Index, 
     main = "Scatterplot Corruption_Index vs Education_Index",
     xlab = "Corruption_Index", ylab = "Education_Index",
     col = "darkgreen", pch = 16)