setwd("/home/daria/Courses/R/Edx/Intro/")
who <- read.csv('WHO.csv')
who_europe <- subset(who, Region == "Europe")
sd(who$Under15)
## [1] 10.53457
summary(who$Under15)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 13.12 18.72 28.65 28.73 37.75 49.99
# returns row value for country with minimum value
which.min(who$Under15)
## [1] 86
# returns country of given row
who$Country[86]
## [1] Japan
## 194 Levels: Afghanistan Albania Algeria Andorra ... Zimbabwe
# for max
which.max(who$Under15)
## [1] 124
who$Country[124]
## [1] Niger
## 194 Levels: Afghanistan Albania Algeria Andorra ... Zimbabwe
plot(who$GNI, who$FertilityRate)

Outliers <- subset(who, GNI > 10000 & FertilityRate > 2.5)
nrow(Outliers)
## [1] 7
Outliers[c("Country","GNI","FertilityRate")]
## Country GNI FertilityRate
## 23 Botswana 14550 2.71
## 56 Equatorial Guinea 25620 5.04
## 63 Gabon 13740 4.18
## 83 Israel 27110 2.92
## 88 Kazakhstan 11250 2.52
## 131 Panama 14510 2.52
## 150 Saudi Arabia 24700 2.76
hist(who$CellularSubscribers)

boxplot(who$LifeExpectancy ~ who$Region)

table(who$Region)
##
## Africa Americas Eastern Mediterranean
## 46 35 22
## Europe South-East Asia Western Pacific
## 53 11 27
# avr % of population over 60 in diff regions
tapply(who$Over60, who$Region, mean)
## Africa Americas Eastern Mediterranean
## 5.220652 10.943714 5.620000
## Europe South-East Asia Western Pacific
## 19.774906 8.769091 10.162963
tapply(who$LiteracyRate, who$Region, min, na.rm = TRUE)
## Africa Americas Eastern Mediterranean
## 31.1 75.2 63.9
## Europe South-East Asia Western Pacific
## 95.2 56.8 60.6