#Bohdan
#Bohdan Ilnitskyi
#2024-03-06
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(carData)
## Warning: package 'carData' was built under R version 4.3.3
data("UN")
dat<-UN %>%
rename(країна= region,групи=group,регіон=fertility,народжуваність=ppgdp,рівинь_життя=lifeExpF,місто=pctUrban, дитяча_смертність=infantMortality)
dat<-dat %>%
filter(країна == "Europe")
dat<- dat %>%
mutate(групи = if_else(групи %in% c("OECD", "EU"), "OECD", "other"))
dat<-dat %>%
mutate(Пропорція = рівинь_життя / 100)
group <- dat %>%
group_by(групи) %>%
summarise(across(where(is.numeric), mean))
print(group)
## # A tibble: 1 × 7
## групи регіон народжуваність рівинь_життя місто дитяча_смертність Пропорція
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 other 1.59 27394. 80.7 70.5 6.12 0.807
mean_d <- dat %>%
summarise(across(where(is.numeric) & !contains(names(.), "рівинь_життя", ignore.case = FALSE), mean))
print(mean_d)
## регіон народжуваність рівинь_життя місто дитяча_смертність Пропорція
## 1 1.590026 27393.94 80.69077 70.46154 6.121744 0.8069077
sorted_d <- dat %>%
arrange(рівинь_життя)
print(sorted_d)
## країна групи регіон народжуваність рівинь_життя місто
## Moldova Europe other 1.450 1625.8 73.48 48
## Ukraine Europe other 1.483 3035.0 74.58 69
## Russian Federation Europe other 1.529 10351.4 75.01 73
## Belarus Europe other 1.479 5702.0 76.37 75
## Serbia Europe other 1.562 5123.2 77.05 56
## Bulgaria Europe other 1.546 6365.1 77.12 72
## TFYR Macedonia Europe other 1.397 4434.5 77.14 59
## Montenegro Europe other 1.630 6509.8 77.37 61
## Romania Europe other 1.428 7522.4 77.95 58
## Lithuania Europe other 1.495 10975.5 78.28 67
## Bosnia and Herzegovina Europe other 1.134 4477.7 78.40 49
## Hungary Europe other 1.430 12884.0 78.47 68
## Latvia Europe other 1.506 10663.0 78.51 68
## Slovakia Europe other 1.372 15976.0 79.53 55
## Estonia Europe other 1.702 14135.4 79.95 70
## Croatia Europe other 1.501 13819.5 80.37 58
## Albania Europe other 1.525 3677.2 80.40 53
## Poland Europe other 1.415 12263.2 80.56 61
## Czech Republic Europe other 1.501 18838.8 81.00 74
## Denmark Europe other 1.885 55830.2 81.37 87
## Malta Europe other 1.284 19599.2 82.29 95
## United Kingdom Europe other 1.867 36326.8 82.42 80
## Greece Europe other 1.540 26503.8 82.58 62
## Luxembourg Europe other 1.683 105095.4 82.67 85
## Portugal Europe other 1.312 21437.6 82.76 61
## Netherlands Europe other 1.794 46909.7 82.79 83
## Belgium Europe other 1.835 43814.8 82.81 97
## Slovenia Europe other 1.477 23109.8 82.84 49
## Germany Europe other 1.457 39857.1 82.99 74
## Ireland Europe other 2.097 46220.3 83.17 62
## Finland Europe other 1.875 44501.7 83.28 85
## Norway Europe other 1.948 84588.7 83.47 80
## Austria Europe other 1.346 45158.8 83.55 68
## Sweden Europe other 1.925 48906.2 83.65 85
## Iceland Europe other 2.098 39278.0 83.77 94
## Italy Europe other 1.476 33877.1 84.62 69
## Switzerland Europe other 1.536 68880.2 84.71 74
## Spain Europe other 1.504 30542.8 84.76 78
## France Europe other 1.987 39545.9 84.90 86
## дитяча_смертність Пропорція
## Moldova 14.344 0.7348
## Ukraine 11.822 0.7458
## Russian Federation 10.534 0.7501
## Belarus 6.494 0.7637
## Serbia 10.630 0.7705
## Bulgaria 9.149 0.7712
## TFYR Macedonia 13.063 0.7714
## Montenegro 7.733 0.7737
## Romania 12.216 0.7795
## Lithuania 5.941 0.7828
## Bosnia and Herzegovina 12.695 0.7840
## Hungary 5.304 0.7847
## Latvia 6.700 0.7851
## Slovakia 5.676 0.7953
## Estonia 4.382 0.7995
## Croatia 5.571 0.8037
## Albania 16.561 0.8040
## Poland 5.546 0.8056
## Czech Republic 2.997 0.8100
## Denmark 3.914 0.8137
## Malta 5.405 0.8229
## United Kingdom 4.702 0.8242
## Greece 4.488 0.8258
## Luxembourg 2.289 0.8267
## Portugal 4.175 0.8276
## Netherlands 4.168 0.8279
## Belgium 3.739 0.8281
## Slovenia 3.279 0.8284
## Germany 3.487 0.8299
## Ireland 3.859 0.8317
## Finland 2.783 0.8328
## Norway 2.940 0.8347
## Austria 3.713 0.8355
## Sweden 2.544 0.8365
## Iceland 2.057 0.8377
## Italy 3.417 0.8462
## Switzerland 3.513 0.8471
## Spain 3.573 0.8476
## France 3.345 0.8490