Skip to content

sanaakadi/IODS-projechttps-github.com-sanaakadi-IODS-project-settingst

 
 

Repository files navigation

IODS-project

Template for the IODS course https://github.com/sanaakadi/IODS-projechttps-github.com-sanaakadi-IODS-project-settingst

learning2014 is available

print out the column names of the data

colnames(learning2014)

change the name of the second column

colnames(learning2014)[2] <- "age"

change the name of "Points" to "points"

colnames(learning2014)[7] <- "points"

print out the new column names of the data

colnames(learning2014)

read the data into memory

lrn14 <- read.table("http://www.helsinki.fi/~kvehkala/JYTmooc/JYTOPKYS3-data.txt", sep="\t", header=TRUE)

Look at the dimensions of the data

dim(lrn14)

Look at the structure of the data

str(lrn14)

learning2014 is available

access the dplyr library

library(dplyr)

select male students

male_students <- filter(learning2014, gender == "M")

select rows where Points is greater than zero

learning2014 <- filter(learning2014, points > 0)

learning2014 is available

Use the gglot2 library

library(ggplot2)

initialize plot with data and aesthetic mapping

p1 <- ggplot(learning2014, aes(x = attitude, y = points, col = gender))

define the visualization type (points)

p2 <- p1 + geom_point()

draw the plot

p2

add a regression line

p3 <- p2 + geom_smooth(method = "lm")

add a main title and draw the plot

p4 <- p3 + ggtitle("Student's attitude versus exam points") p4

learning2014 is available

draw a scatter plot matrix of the variables in learning2014.

[-1] excludes the first column (gender)

pairs(learning2014[-1], col = learning2014$gender)

access the GGally and ggplot2 libraries

library(GGally) library(ggplot2)

create a more advanced plot matrix with ggpairs()

p <- ggpairs(learning2014, mapping = aes(col = gender, alpha = 0.3), lower = list(combo = wrap("facethist", bins = 20)))

draw the plot

p

learning2014 is available

a scatter plot of points versus attitude

library(ggplot2) qplot(attitude, points, data = learning2014) + geom_smooth(method = "lm")

fit a linear model

my_model <- lm(points ~ attitude, data = learning2014)

print out a summary of the model

summary(my_model)

learning2014, GGally, ggplot2 are available

create an plot matrix with ggpairs()

ggpairs(learning2014, lower = list(combo = wrap("facethist", bins = 20)))

create a regression model with multiple explanatory variables

my_model2 <- lm(points ~ attitude + stra + surf, data = learning2014)

print out a summary of the model

summary(my_model2)

access the MASS package

library(MASS)

load the data

data("Boston")

explore the dataset

str(Boston) 'data.frame': 506 obs. of 14 variables: $ crim : num 0.00632 0.02731 0.02729 0.03237 0.06905 ... $ zn : num 18 0 0 0 0 0 12.5 12.5 12.5 12.5 ... $ indus : num 2.31 7.07 7.07 2.18 2.18 2.18 7.87 7.87 7.87 7.87 ... $ chas : int 0 0 0 0 0 0 0 0 0 0 ... $ nox : num 0.538 0.469 0.469 0.458 0.458 0.458 0.524 0.524 0.524 0.524 ... $ rm : num 6.58 6.42 7.18 7 7.15 ... $ age : num 65.2 78.9 61.1 45.8 54.2 58.7 66.6 96.1 100 85.9 ... $ dis : num 4.09 4.97 4.97 6.06 6.06 ... $ rad : int 1 2 2 3 3 3 5 5 5 5 ... $ tax : num 296 242 242 222 222 222 311 311 311 311 ... $ ptratio: num 15.3 17.8 17.8 18.7 18.7 18.7 15.2 15.2 15.2 15.2 ... $ black : num 397 397 393 395 397 ... $ lstat : num 4.98 9.14 4.03 2.94 5.33 ... $ medv : num 24 21.6 34.7 33.4 36.2 28.7 22.9 27.1 16.5 18.9 ... summary(Boston) crim zn indus chas
Min. : 0.00632 Min. : 0.00 Min. : 0.46 Min. :0.00000
1st Qu.: 0.08204 1st Qu.: 0.00 1st Qu.: 5.19 1st Qu.:0.00000
Median : 0.25651 Median : 0.00 Median : 9.69 Median :0.00000
Mean : 3.61352 Mean : 11.36 Mean :11.14 Mean :0.06917
3rd Qu.: 3.67708 3rd Qu.: 12.50 3rd Qu.:18.10 3rd Qu.:0.00000
Max. :88.97620 Max. :100.00 Max. :27.74 Max. :1.00000
nox rm age dis
Min. :0.3850 Min. :3.561 Min. : 2.90 Min. : 1.130
1st Qu.:0.4490 1st Qu.:5.886 1st Qu.: 45.02 1st Qu.: 2.100
Median :0.5380 Median :6.208 Median : 77.50 Median : 3.207
Mean :0.5547 Mean :6.285 Mean : 68.57 Mean : 3.795
3rd Qu.:0.6240 3rd Qu.:6.623 3rd Qu.: 94.08 3rd Qu.: 5.188
Max. :0.8710 Max. :8.780 Max. :100.00 Max. :12.127
rad tax ptratio black
Min. : 1.000 Min. :187.0 Min. :12.60 Min. : 0.32
1st Qu.: 4.000 1st Qu.:279.0 1st Qu.:17.40 1st Qu.:375.38
Median : 5.000 Median :330.0 Median :19.05 Median :391.44
Mean : 9.549 Mean :408.2 Mean :18.46 Mean :356.67
3rd Qu.:24.000 3rd Qu.:666.0 3rd Qu.:20.20 3rd Qu.:396.23
Max. :24.000 Max. :711.0 Max. :22.00 Max. :396.90
lstat medv
Min. : 1.73 Min. : 5.00
1st Qu.: 6.95 1st Qu.:17.02
Median :11.36 Median :21.20
Mean :12.65 Mean :22.53
3rd Qu.:16.95 3rd Qu.:25.00
Max. :37.97 Max. :50.00

plot matrix of the variables

pairs(Boston)

MASS, corrplot, tidyr and Boston dataset are available

calculate the correlation matrix and round it

cor_matrix<-cor(Boston) %>% round(digits = 2)

print the correlation matrix

cor_matrix

visualize the correlation matrix

corrplot(cor_matrix, method="circle", type="upper", cl.pos="b", tl.pos="d", tl.cex = 0.6)

MASS, corrplot, tidyr and Boston dataset are available

calculate the correlation matrix and round it

cor_matrix<-cor(Boston) %>% round(digits = 2)

print the correlation matrix

cor_matrix crim zn indus chas nox rm age dis rad tax ptratio crim 1.00 -0.20 0.41 -0.06 0.42 -0.22 0.35 -0.38 0.63 0.58 0.29 zn -0.20 1.00 -0.53 -0.04 -0.52 0.31 -0.57 0.66 -0.31 -0.31 -0.39 indus 0.41 -0.53 1.00 0.06 0.76 -0.39 0.64 -0.71 0.60 0.72 0.38 chas -0.06 -0.04 0.06 1.00 0.09 0.09 0.09 -0.10 -0.01 -0.04 -0.12 nox 0.42 -0.52 0.76 0.09 1.00 -0.30 0.73 -0.77 0.61 0.67 0.19 rm -0.22 0.31 -0.39 0.09 -0.30 1.00 -0.24 0.21 -0.21 -0.29 -0.36 age 0.35 -0.57 0.64 0.09 0.73 -0.24 1.00 -0.75 0.46 0.51 0.26 dis -0.38 0.66 -0.71 -0.10 -0.77 0.21 -0.75 1.00 -0.49 -0.53 -0.23 rad 0.63 -0.31 0.60 -0.01 0.61 -0.21 0.46 -0.49 1.00 0.91 0.46 tax 0.58 -0.31 0.72 -0.04 0.67 -0.29 0.51 -0.53 0.91 1.00 0.46 ptratio 0.29 -0.39 0.38 -0.12 0.19 -0.36 0.26 -0.23 0.46 0.46 1.00 black -0.39 0.18 -0.36 0.05 -0.38 0.13 -0.27 0.29 -0.44 -0.44 -0.18 lstat 0.46 -0.41 0.60 -0.05 0.59 -0.61 0.60 -0.50 0.49 0.54 0.37 medv -0.39 0.36 -0.48 0.18 -0.43 0.70 -0.38 0.25 -0.38 -0.47 -0.51 black lstat medv crim -0.39 0.46 -0.39 zn 0.18 -0.41 0.36 indus -0.36 0.60 -0.48 chas 0.05 -0.05 0.18 nox -0.38 0.59 -0.43 rm 0.13 -0.61 0.70 age -0.27 0.60 -0.38 dis 0.29 -0.50 0.25 rad -0.44 0.49 -0.38 tax -0.44 0.54 -0.47 ptratio -0.18 0.37 -0.51 black 1.00 -0.37 0.33 lstat -0.37 1.00 -0.74 medv 0.33 -0.74 1.00

visualize the correlation matrix

corrplot(cor_matrix, method="circle", type="upper", cl.pos="b", tl.pos="d", tl.cex = 0.6)

access the MASS package

library(MASS)

load the data

data("Boston")

explore the dataset

str(Boston) 'data.frame': 506 obs. of 14 variables: $ crim : num 0.00632 0.02731 0.02729 0.03237 0.06905 ... $ zn : num 18 0 0 0 0 0 12.5 12.5 12.5 12.5 ... $ indus : num 2.31 7.07 7.07 2.18 2.18 2.18 7.87 7.87 7.87 7.87 ... $ chas : int 0 0 0 0 0 0 0 0 0 0 ... $ nox : num 0.538 0.469 0.469 0.458 0.458 0.458 0.524 0.524 0.524 0.524 ... $ rm : num 6.58 6.42 7.18 7 7.15 ... $ age : num 65.2 78.9 61.1 45.8 54.2 58.7 66.6 96.1 100 85.9 ... $ dis : num 4.09 4.97 4.97 6.06 6.06 ... $ rad : int 1 2 2 3 3 3 5 5 5 5 ... $ tax : num 296 242 242 222 222 222 311 311 311 311 ... $ ptratio: num 15.3 17.8 17.8 18.7 18.7 18.7 15.2 15.2 15.2 15.2 ... $ black : num 397 397 393 395 397 ... $ lstat : num 4.98 9.14 4.03 2.94 5.33 ... $ medv : num 24 21.6 34.7 33.4 36.2 28.7 22.9 27.1 16.5 18.9 ... summary(Boston) crim zn indus chas
Min. : 0.00632 Min. : 0.00 Min. : 0.46 Min. :0.00000
1st Qu.: 0.08204 1st Qu.: 0.00 1st Qu.: 5.19 1st Qu.:0.00000
Median : 0.25651 Median : 0.00 Median : 9.69 Median :0.00000
Mean : 3.61352 Mean : 11.36 Mean :11.14 Mean :0.06917
3rd Qu.: 3.67708 3rd Qu.: 12.50 3rd Qu.:18.10 3rd Qu.:0.00000
Max. :88.97620 Max. :100.00 Max. :27.74 Max. :1.00000
nox rm age dis
Min. :0.3850 Min. :3.561 Min. : 2.90 Min. : 1.130
1st Qu.:0.4490 1st Qu.:5.886 1st Qu.: 45.02 1st Qu.: 2.100
Median :0.5380 Median :6.208 Median : 77.50 Median : 3.207
Mean :0.5547 Mean :6.285 Mean : 68.57 Mean : 3.795
3rd Qu.:0.6240 3rd Qu.:6.623 3rd Qu.: 94.08 3rd Qu.: 5.188
Max. :0.8710 Max. :8.780 Max. :100.00 Max. :12.127
rad tax ptratio black
Min. : 1.000 Min. :187.0 Min. :12.60 Min. : 0.32
1st Qu.: 4.000 1st Qu.:279.0 1st Qu.:17.40 1st Qu.:375.38
Median : 5.000 Median :330.0 Median :19.05 Median :391.44
Mean : 9.549 Mean :408.2 Mean :18.46 Mean :356.67
3rd Qu.:24.000 3rd Qu.:666.0 3rd Qu.:20.20 3rd Qu.:396.23
Max. :24.000 Max. :711.0 Max. :22.00 Max. :396.90
lstat medv
Min. : 1.73 Min. : 5.00
1st Qu.: 6.95 1st Qu.:17.02
Median :11.36 Median :21.20
Mean :12.65 Mean :22.53
3rd Qu.:16.95 3rd Qu.:25.00
Max. :37.97 Max. :50.00

plot matrix of the variables

pairs(Boston)

MASS, corrplot, tidyr and Boston dataset are available

calculate the correlation matrix and round it

cor_matrix<-cor(Boston) %>% round(digits = 2)

print the correlation matrix

cor_matrix crim zn indus chas nox rm age dis rad tax ptratio crim 1.00 -0.20 0.41 -0.06 0.42 -0.22 0.35 -0.38 0.63 0.58 0.29 zn -0.20 1.00 -0.53 -0.04 -0.52 0.31 -0.57 0.66 -0.31 -0.31 -0.39 indus 0.41 -0.53 1.00 0.06 0.76 -0.39 0.64 -0.71 0.60 0.72 0.38 chas -0.06 -0.04 0.06 1.00 0.09 0.09 0.09 -0.10 -0.01 -0.04 -0.12 nox 0.42 -0.52 0.76 0.09 1.00 -0.30 0.73 -0.77 0.61 0.67 0.19 rm -0.22 0.31 -0.39 0.09 -0.30 1.00 -0.24 0.21 -0.21 -0.29 -0.36 age 0.35 -0.57 0.64 0.09 0.73 -0.24 1.00 -0.75 0.46 0.51 0.26 dis -0.38 0.66 -0.71 -0.10 -0.77 0.21 -0.75 1.00 -0.49 -0.53 -0.23 rad 0.63 -0.31 0.60 -0.01 0.61 -0.21 0.46 -0.49 1.00 0.91 0.46 tax 0.58 -0.31 0.72 -0.04 0.67 -0.29 0.51 -0.53 0.91 1.00 0.46 ptratio 0.29 -0.39 0.38 -0.12 0.19 -0.36 0.26 -0.23 0.46 0.46 1.00 black -0.39 0.18 -0.36 0.05 -0.38 0.13 -0.27 0.29 -0.44 -0.44 -0.18 lstat 0.46 -0.41 0.60 -0.05 0.59 -0.61 0.60 -0.50 0.49 0.54 0.37 medv -0.39 0.36 -0.48 0.18 -0.43 0.70 -0.38 0.25 -0.38 -0.47 -0.51 black lstat medv crim -0.39 0.46 -0.39 zn 0.18 -0.41 0.36 indus -0.36 0.60 -0.48 chas 0.05 -0.05 0.18 nox -0.38 0.59 -0.43 rm 0.13 -0.61 0.70 age -0.27 0.60 -0.38 dis 0.29 -0.50 0.25 rad -0.44 0.49 -0.38 tax -0.44 0.54 -0.47 ptratio -0.18 0.37 -0.51 black 1.00 -0.37 0.33 lstat -0.37 1.00 -0.74 medv 0.33 -0.74 1.00

visualize the correlation matrix

corrplot(cor_matrix, method="circle", type="upper", cl.pos="b", tl.pos="d", tl.cex = 0.6)

MASS and Boston dataset are available

center and standardize variables

boston_scaled <- scale(Boston)

summaries of the scaled variables

summary(boston_scaled) crim zn indus chas
Min. :-0.419367 Min. :-0.48724 Min. :-1.5563 Min. :-0.2723
1st Qu.:-0.410563 1st Qu.:-0.48724 1st Qu.:-0.8668 1st Qu.:-0.2723
Median :-0.390280 Median :-0.48724 Median :-0.2109 Median :-0.2723
Mean : 0.000000 Mean : 0.00000 Mean : 0.0000 Mean : 0.0000
3rd Qu.: 0.007389 3rd Qu.: 0.04872 3rd Qu.: 1.0150 3rd Qu.:-0.2723
Max. : 9.924110 Max. : 3.80047 Max. : 2.4202 Max. : 3.6648
nox rm age dis
Min. :-1.4644 Min. :-3.8764 Min. :-2.3331 Min. :-1.2658
1st Qu.:-0.9121 1st Qu.:-0.5681 1st Qu.:-0.8366 1st Qu.:-0.8049
Median :-0.1441 Median :-0.1084 Median : 0.3171 Median :-0.2790
Mean : 0.0000 Mean : 0.0000 Mean : 0.0000 Mean : 0.0000
3rd Qu.: 0.5981 3rd Qu.: 0.4823 3rd Qu.: 0.9059 3rd Qu.: 0.6617
Max. : 2.7296 Max. : 3.5515 Max. : 1.1164 Max. : 3.9566
rad tax ptratio black
Min. :-0.9819 Min. :-1.3127 Min. :-2.7047 Min. :-3.9033
1st Qu.:-0.6373 1st Qu.:-0.7668 1st Qu.:-0.4876 1st Qu.: 0.2049
Median :-0.5225 Median :-0.4642 Median : 0.2746 Median : 0.3808
Mean : 0.0000 Mean : 0.0000 Mean : 0.0000 Mean : 0.0000
3rd Qu.: 1.6596 3rd Qu.: 1.5294 3rd Qu.: 0.8058 3rd Qu.: 0.4332
Max. : 1.6596 Max. : 1.7964 Max. : 1.6372 Max. : 0.4406
lstat medv
Min. :-1.5296 Min. :-1.9063
1st Qu.:-0.7986 1st Qu.:-0.5989
Median :-0.1811 Median :-0.1449
Mean : 0.0000 Mean : 0.0000
3rd Qu.: 0.6024 3rd Qu.: 0.2683
Max. : 3.5453 Max. : 2.9865

class of the boston_scaled object

class(boston_scaled) [1] "matrix"

change the object to data frame

boston_scaled <- as.data.frame(boston_scaled) create_human.R "HDI.Rank","Country","HDI","Life.Exp","Edu.Exp","Edu.Mean","GNI","GNI.Minus.Rank","GII.Rank","GII","Mat.Mor","Ado.Birth","Parli.F","Edu2.F","Edu2.M","Labo.F","Labo.M","Edu2.FM","Labo.FM" 1,"Norway",0.944,81.6,17.5,12.6,"64,992",5,1,0.067,4,7.8,39.6,97.4,96.7,61.2,68.7,1.00723888314374,0.890829694323144 2,"Australia",0.935,82.4,20.2,13,"42,261",17,2,0.11,6,12.1,30.5,94.3,94.6,58.8,71.8,0.996828752642706,0.818941504178273 3,"Switzerland",0.93,83,15.8,12.8,"56,431",6,3,0.028,6,1.9,28.5,95,96.6,61.8,74.9,0.98343685300207,0.825100133511348 4,"Denmark",0.923,80.2,18.7,12.7,"44,025",11,4,0.048,5,5.1,38,95.5,96.6,58.7,66.4,0.988612836438924,0.884036144578313 5,"Netherlands",0.922,81.6,17.9,11.9,"45,435",9,5,0.062,6,6.2,36.9,87.7,90.5,58.5,70.6,0.969060773480663,0.828611898016997 6,"Germany",0.916,80.9,16.5,13.1,"43,919",11,6,0.041,7,3.8,36.9,96.3,97,53.6,66.4,0.992783505154639,0.807228915662651 6,"Ireland",0.916,80.9,18.6,12.2,"39,568",16,6,0.113,9,8.2,19.9,80.5,78.6,53.1,68.1,1.02417302798982,0.779735682819383 8,"United States",0.915,79.1,16.5,12.9,"52,947",3,8,0.28,28,31,19.4,95.1,94.8,56.3,68.9,1.00316455696203,0.817126269956459 9,"Canada",0.913,82,15.9,13,"42,155",11,9,0.129,11,14.5,28.2,100,100,61.6,71,1,0.867605633802817 9,"New Zealand",0.913,81.8,19.2,12.5,"32,689",23,9,0.157,8,25.3,31.4,95,95.3,62,73.8,0.99685204616999,0.840108401084011 11,"Singapore",0.912,83,15.4,10.6,"76,628",-7,11,0.088,6,6,25.3,74.1,81,58.8,77.2,0.914814814814815,0.761658031088083 12,"Hong Kong, China (SAR)",0.91,84,15.6,11.2,"53,959",-2,12,NA,NA,3.3,NA,72.2,79.2,51.3,67.8,0.911616161616162,0.756637168141593 13,"Liechtenstein",0.908,80,15,11.8,"79,851",-10,13,NA,NA,NA,20,NA,NA,NA,NA,NA,NA 14,"Sweden",0.907,82.2,15.8,12.1,"45,636",-1,14,0.055,4,6.5,43.6,86.5,87.3,60.3,67.9,0.990836197021764,0.888070692194403 14,"United Kingdom",0.907,80.7,16.2,13.1,"39,267",9,14,0.177,8,25.8,23.5,99.8,99.9,55.7,68.7,0.998998998998999,0.810771470160116 16,"Iceland",0.899,82.6,19,10.6,"35,182",12,16,0.087,4,11.5,41.3,91,91.6,70.5,77.4,0.993449781659389,0.910852713178295 17,"Korea (Republic of)",0.898,81.9,16.9,11.9,"33,890",13,17,0.125,27,2.2,16.3,77,89.1,50.1,72.1,0.864197530864198,0.694868238557559 18,"Israel",0.894,82.4,16,12.5,"30,676",16,18,0.101,2,7.8,22.5,84.4,87.3,57.9,69.1,0.966781214203895,0.837916063675832 19,"Luxembourg",0.892,81.7,13.9,11.7,"58,711",-11,19,0.1,11,8.3,28.3,100,100,50.7,64.6,1,0.784829721362229 20,"Japan",0.891,83.5,15.3,11.5,"36,927",7,20,0.133,6,5.4,11.6,87,85.8,48.8,70.4,1.01398601398601,0.693181818181818 21,"Belgium",0.89,80.8,16.3,11.3,"41,187",0,21,0.063,6,6.7,42.4,77.5,82.9,47.5,59.3,0.934861278648975,0.801011804384486 22,"France",0.888,82.2,16,11.1,"38,056",4,22,0.088,12,5.7,25.7,78,83.2,50.7,61.6,0.9375,0.823051948051948 23,"Austria",0.885,81.4,15.7,10.8,"43,869",-5,23,0.053,4,4.1,30.3,100,100,54.6,67.7,1,0.806499261447563 24,"Finland",0.883,80.8,17.1,10.3,"38,695",0,24,0.075,4,9.2,42.5,100,100,55.7,64,1,0.8703125 25,"Slovenia",0.88,80.4,16.8,11.9,"27,852",12,25,0.016,7,0.6,27.7,95.8,98,52.3,63.2,0.977551020408163,0.82753164556962 26,"Spain",0.876,82.6,17.3,9.6,"32,045",7,26,0.095,4,10.6,38,66.8,73.1,52.5,65.8,0.913816689466484,0.797872340425532 27,"Italy",0.873,83.1,16,10.1,"33,030",4,27,0.068,4,4,30.1,71.2,80.5,39.6,59.5,0.884472049689441,0.665546218487395 28,"Czech Republic",0.87,78.6,16.4,12.3,"26,660",10,28,0.091,5,4.9,18.9,99.9,99.7,51.1,68.3,1.00200601805416,0.748169838945827 29,"Greece",0.865,80.9,17.6,10.3,"24,524",14,29,0.146,5,11.9,21,59.5,67,44.2,62.5,0.888059701492537,0.7072 30,"Estonia",0.861,76.8,16.5,12.5,"25,214",12,30,0.164,11,16.8,19.8,100,100,56.2,68.9,1,0.815674891146589 31,"Brunei Darussalam",0.856,78.8,14.5,8.8,"72,570",-26,31,NA,27,23,NA,63.9,67.8,52.6,75.3,0.942477876106195,0.698539176626826 32,"Cyprus",0.85,80.2,14,11.6,"28,633",3,32,0.124,10,5.5,12.5,76,81.7,56,71.1,0.930232558139535,0.787623066104079 32,"Qatar",0.85,78.2,13.8,9.1,"123,124",-31,32,0.524,6,9.5,0,66.7,59,50.8,95.5,1.13050847457627,0.531937172774869 34,"Andorra",0.845,81.3,13.5,9.6,"43,978",-18,34,NA,NA,NA,50,49.5,49.3,NA,NA,1.00405679513185,NA 35,"Slovakia",0.844,76.3,15.1,12.2,"25,845",5,35,0.164,7,15.9,18.7,99.1,99.5,51.1,68.6,0.995979899497487,0.744897959183674 36,"Poland",0.843,77.4,15.5,11.8,"23,177",10,36,0.138,3,12.2,22.1,79.4,85.5,48.9,64.9,0.928654970760234,0.75346687211094 37,"Lithuania",0.839,73.3,16.4,12.4,"24,500",7,37,0.125,11,10.6,23.4,89.1,94.3,55.8,67.3,0.944856839872746,0.829123328380386 37,"Malta",0.839,80.6,14.4,10.3,"27,930",-1,37,0.227,9,18.2,13,68.6,78.2,37.9,66.3,0.877237851662404,0.571644042232277 39,"Saudi Arabia",0.837,74.3,16.3,8.7,"52,821",-27,39,0.284,16,10.2,19.9,60.5,70.3,20.2,78.3,0.860597439544808,0.257982120051086 40,"Argentina",0.836,76.3,17.9,9.8,"22,050",11,40,0.376,69,54.4,36.8,56.3,57.6,47.5,75,0.977430555555555,0.633333333333333 41,"United Arab Emirates",0.835,77,13.3,9.5,"60,868",-34,41,0.232,8,27.6,17.5,73.1,61.2,46.5,92,1.19444444444444,0.505434782608696 42,"Chile",0.832,81.7,15.2,9.8,"21,290",11,42,0.338,22,55.3,15.8,73.3,76.4,49.2,74.8,0.959424083769633,0.657754010695187 43,"Portugal",0.83,80.9,16.3,8.2,"25,757",-2,43,0.111,8,12.6,31.3,47.7,48.2,54.9,66.2,0.989626556016598,0.829305135951662 44,"Hungary",0.828,75.2,15.4,11.6,"22,916",3,44,0.209,14,12.1,10.1,97.9,98.7,44.8,60,0.991894630192503,0.746666666666667 45,"Bahrain",0.824,76.6,14.4,9.4,"38,599",-20,45,0.265,22,13.8,15,56.7,51.4,39.2,86.9,1.10311284046693,0.451093210586881 46,"Latvia",0.819,74.2,15.2,11.5,"22,281",4,46,0.167,13,13.5,18,98.9,99,54.9,67.6,0.998989898989899,0.812130177514793 47,"Croatia",0.818,77.3,14.8,11,"19,409",11,47,0.149,13,12.7,25.8,85,93.6,44.7,58.4,0.908119658119658,0.76541095890411 48,"Kuwait",0.816,74.4,14.7,7.2,"83,961",-46,48,0.387,14,14.5,1.5,55.6,56.3,43.6,83.1,0.987566607460036,0.524669073405536 49,"Montenegro",0.802,76.2,15.2,11.2,"14,558",27,49,0.171,7,15.2,17.3,84.2,94.7,43,57.3,0.889123548046463,0.75043630017452 50,"Belarus",0.798,71.3,15.7,12,"16,676",14,50,0.151,1,20.6,30.1,87,92.2,50.1,63.1,0.943600867678959,0.793977812995246 50,"Russian Federation",0.798,70.1,14.7,12,"22,352",-1,50,0.276,24,25.7,14.5,89.6,92.5,57.1,71.7,0.968648648648649,0.796373779637378 52,"Oman",0.793,76.8,13.6,8,"34,858",-23,52,0.275,11,10.6,9.6,47.2,57.1,29,82.6,0.82661996497373,0.351089588377724 52,"Romania",0.793,74.7,14.2,10.8,"18,108",10,52,0.333,33,31,12,86.1,92,48.7,64.9,0.935869565217391,0.750385208012327 52,"Uruguay",0.793,77.2,15.5,8.5,"19,283",7,52,0.313,14,58.3,11.5,54.4,50.3,55.6,76.8,1.08151093439364,0.723958333333333 55,"Bahamas",0.79,75.4,12.6,10.9,"21,336",-3,55,0.298,37,28.5,16.7,91.2,87.6,69.3,79.3,1.04109589041096,0.873896595208071 56,"Kazakhstan",0.788,69.4,15,11.4,"20,867",-1,56,0.267,26,29.9,20.1,95.3,98.8,67.7,77.9,0.964574898785425,0.869062901155327 57,"Barbados",0.785,75.6,15.4,10.5,"12,488",27,57,0.357,52,48.4,19.6,89.5,87.7,65.9,76.6,1.02052451539339,0.860313315926893 58,"Antigua and Barbuda",0.783,76.1,14,9.2,"20,070",-1,58,NA,NA,49.3,25.7,NA,NA,NA,NA,NA,NA 59,"Bulgaria",0.782,74.2,14.4,10.6,"15,596",13,59,0.212,5,35.9,20.4,93,95.7,47.9,59,0.971786833855799,0.811864406779661 60,"Palau",0.78,72.7,13.7,12.3,"13,496",18,60,NA,NA,NA,10.3,NA,NA,NA,NA,NA,NA 60,"Panama",0.78,77.6,13.3,9.3,"18,192",1,60,0.454,85,78.5,19.3,54,49.9,49,81.8,1.08216432865731,0.599022004889976 62,"Malaysia",0.779,74.7,12.7,10,"22,762",-14,62,0.209,29,5.7,14.2,65.1,71.3,44.4,75.5,0.91304347826087,0.588079470198675 63,"Mauritius",0.777,74.4,15.6,8.5,"17,470",0,63,0.419,73,30.9,11.6,49.4,58,43.6,74.2,0.851724137931034,0.587601078167116 64,"Seychelles",0.772,73.1,13.4,9.4,"23,300",-19,64,NA,NA,56.3,43.8,66.9,66.6,NA,NA,1.0045045045045,NA 64,"Trinidad and Tobago",0.772,70.4,12.3,10.9,"26,090",-25,64,0.371,84,34.8,24.7,59.7,60.9,53,75.5,0.980295566502463,0.701986754966887 66,"Serbia",0.771,74.9,14.4,10.5,"12,190",20,66,0.176,16,16.9,34,58.4,73.6,44.5,60.9,0.793478260869565,0.730706075533662 67,"Cuba",0.769,79.4,13.8,11.5,"7,301",47,67,0.356,80,43.1,48.9,74.3,78.8,43.4,70,0.942893401015228,0.62 67,"Lebanon",0.769,79.3,13.8,7.9,"16,509",-1,67,0.385,16,12,3.1,53,55.4,23.3,70.9,0.956678700361011,0.328631875881523 69,"Costa Rica",0.766,79.4,13.9,8.4,"13,413",10,69,0.349,38,60.8,33.3,50.7,50.5,46.6,79,1.0039603960396,0.589873417721519 69,"Iran (Islamic Republic of)",0.766,75.4,15.1,8.2,"15,440",4,69,0.515,23,31.6,3.1,62.2,67.6,16.6,73.6,0.920118343195266,0.22554347826087 71,"Venezuela (Bolivarian Republic of)",0.762,74.2,14.2,8.9,"16,159",-2,71,0.476,110,83.2,17,56.6,50.8,51.1,79.2,1.11417322834646,0.64520202020202 72,"Turkey",0.761,75.3,14.5,7.6,"18,677",-12,72,0.359,20,30.9,14.4,39,60,29.4,70.8,0.65,0.415254237288136 73,"Sri Lanka",0.757,74.9,13.7,10.8,"9,779",29,73,0.37,29,16.9,5.8,72.7,76.4,35.1,76.3,0.951570680628272,0.46002621231979 74,"Mexico",0.756,76.8,13.1,8.5,"16,056",-4,74,0.373,49,63.4,37.1,55.7,60.6,45.1,79.9,0.919141914191419,0.564455569461827 75,"Brazil",0.755,74.5,15.2,7.7,"15,175",-1,75,0.457,69,70.8,9.6,54.6,52.4,59.4,80.8,1.04198473282443,0.735148514851485 76,"Georgia",0.754,74.9,13.8,12.1,"7,164",40,76,0.382,41,46.8,11.3,89.7,92.7,56.5,75.1,0.967637540453074,0.752330226364847 77,"Saint Kitts and Nevis",0.752,73.8,12.9,8.4,"20,805",-21,77,NA,NA,NA,6.7,NA,NA,NA,NA,NA,NA 78,"Azerbaijan",0.751,70.8,11.9,11.2,"16,428",-11,78,0.303,26,40,15.6,93.7,97.4,62.9,69.6,0.962012320328542,0.903735632183908 79,"Grenada",0.75,73.4,15.8,8.6,"10,939",14,79,NA,23,35.4,25,NA,NA,NA,NA,NA,NA 80,"Jordan",0.748,74,13.5,9.9,"11,365",11,80,0.473,50,26.5,11.6,69.5,78.5,15.6,66.6,0.885350318471338,0.234234234234234 81,"The former Yugoslav Republic of Macedonia",0.747,75.4,13.4,9.3,"11,780",9,81,0.164,7,18.3,33.3,40.2,55.6,43.1,67.5,0.723021582733813,0.638518518518518 81,"Ukraine",0.747,71,15.1,11.3,"8,178",25,81,0.286,23,25.7,11.8,91.7,95.9,53.2,66.9,0.956204379562044,0.795216741405082 83,"Algeria",0.736,74.8,14,7.6,"13,054",-1,83,0.413,89,10,25.7,26.7,31,15.2,72.2,0.861290322580645,0.210526315789474 84,"Peru",0.734,74.6,13.1,9,"11,015",8,84,0.406,89,50.7,22.3,56.3,66.1,68.2,84.4,0.851739788199697,0.808056872037915 85,"Albania",0.733,77.8,11.8,9.3,"9,943",14,85,0.217,21,15.3,20.7,81.8,87.9,44.9,65.5,0.930602957906712,0.685496183206107 85,"Armenia",0.733,74.7,12.3,10.9,"8,124",22,85,0.318,29,27.1,10.7,94,95,54.2,72.6,0.989473684210526,0.746556473829201 85,"Bosnia and Herzegovina",0.733,76.5,13.6,8.3,"9,638",19,85,0.201,8,15.1,19.3,44.9,69.8,34.1,57.3,0.643266475644699,0.595113438045375 88,"Ecuador",0.732,75.9,14.2,7.6,"10,605",7,88,0.407,87,77,41.6,40.1,39.4,54.7,82.7,1.01776649746193,0.66142684401451 89,"Saint Lucia",0.729,75.1,12.6,9.3,"9,765",14,89,NA,34,56.3,20.7,NA,NA,62.7,76.2,NA,0.822834645669291 90,"China",0.727,75.8,13.1,7.5,"12,547",-7,90,0.191,32,8.6,23.6,58.7,71.9,63.9,78.3,0.816411682892907,0.816091954022989 90,"Fiji",0.727,70,15.7,9.9,"7,493",21,90,0.418,59,42.8,14,64.2,64.5,37.5,72,0.995348837209302,0.520833333333333 90,"Mongolia",0.727,69.4,14.6,9.3,"10,729",4,90,0.325,68,18.7,14.9,85.3,84.1,56.6,69.3,1.01426872770511,0.816738816738817 93,"Thailand",0.726,74.4,13.5,7.3,"13,323",-13,93,0.38,26,41,6.1,35.7,40.8,64.3,80.7,0.875,0.796778190830235 94,"Dominica",0.724,77.8,12.7,7.9,"9,994",4,94,NA,NA,NA,21.9,29.7,23.2,NA,NA,1.2801724137931,NA 94,"Libya",0.724,71.6,14,7.3,"14,911",-19,94,0.134,15,2.5,16,55.5,41.9,30,76.4,1.32458233890215,0.392670157068063 96,"Tunisia",0.721,74.8,14.6,6.8,"10,404",1,96,0.24,46,4.6,31.3,32.8,46.1,25.1,70.9,0.711496746203904,0.354019746121298 97,"Colombia",0.72,74,13.5,7.3,"12,040",-9,97,0.429,83,68.5,20.9,56.9,55.6,55.8,79.7,1.02338129496403,0.700125470514429 97,"Saint Vincent and the Grenadines",0.72,72.9,13.4,8.6,"9,937",3,97,NA,45,54.5,13,NA,NA,55.7,78,NA,0.714102564102564 99,"Jamaica",0.719,75.7,12.4,9.7,"7,415",13,99,0.43,80,70.1,16.7,74,70.2,56.1,70.9,1.05413105413105,0.791255289139633 100,"Tonga",0.717,72.8,14.7,10.7,"5,069",32,100,0.666,120,18.1,0,87.5,88.3,53.5,74.6,0.990939977349943,0.7171581769437 101,"Belize",0.715,70,13.6,10.5,"7,614",9,101,0.426,45,71.4,13.3,76.4,75.8,49.2,82.3,1.00791556728232,0.597812879708384 101,"Dominican Republic",0.715,73.5,13.1,7.6,"11,883",-12,101,0.477,100,99.6,19.1,55.6,53.1,51.3,78.6,1.04708097928437,0.652671755725191 103,"Suriname",0.714,71.1,12.7,7.7,"15,617",-32,103,0.463,130,35.2,11.8,44.6,47.1,40.5,68.8,0.94692144373673,0.588662790697674 104,"Maldives",0.706,76.8,13,5.8,"12,328",-19,104,0.243,31,4.2,5.9,27.3,32.7,56.2,77.5,0.834862385321101,0.725161290322581 105,"Samoa",0.702,73.4,12.9,10.3,"5,327",24,105,0.457,58,28.3,6.1,64.3,60,23.5,58.4,1.07166666666667,0.402397260273973 106,"Botswana",0.698,64.5,12.5,8.9,"16,646",-41,106,0.48,170,44.2,9.5,73.6,77.9,71.9,81.6,0.944801026957638,0.881127450980392 107,"Moldova (Republic of)",0.693,71.6,11.9,11.2,"5,223",23,107,0.248,21,29.3,20.8,93.6,96.6,37.6,44.2,0.968944099378882,0.850678733031674 108,"Egypt",0.69,71.1,13.5,6.6,"10,512",-12,108,0.573,45,43,2.2,43.9,60.6,23.7,74.8,0.724422442244224,0.316844919786096 109,"Turkmenistan",0.688,65.6,10.8,9.9,"13,066",-28,109,NA,61,18,25.8,NA,NA,46.9,76.9,NA,0.609882964889467 110,"Gabon",0.684,64.4,12.5,7.8,"16,367",-42,110,0.514,240,103,16.2,53.9,36.1,56.2,65.4,1.49307479224377,0.859327217125382 110,"Indonesia",0.684,68.9,13,7.6,"9,788",-9,110,0.494,190,48.3,17.1,39.9,49.2,51.4,84.2,0.810975609756098,0.610451306413302 112,"Paraguay",0.679,72.9,11.9,7.7,"7,643",-3,112,0.472,110,67,16.8,36.8,43,55.7,84.8,0.855813953488372,0.65683962264151 113,"Palestine, State of",0.677,72.9,13,8.9,"4,699",21,113,NA,NA,45.8,NA,53.9,59.4,15.4,66.4,0.907407407407407,0.231927710843373 114,"Uzbekistan",0.675,68.4,11.5,10.9,"5,567",10,114,NA,36,38.8,16.4,NA,NA,48.1,75.6,NA,0.636243386243386 115,"Philippines",0.668,68.2,11.3,8.9,"7,915",-7,115,0.42,120,46.8,27.1,65.9,63.7,51.1,79.7,1.03453689167975,0.641154328732748 116,"El Salvador",0.666,73,12.3,6.5,"7,349",-3,116,0.427,69,76,27.4,36.8,43.6,47.8,79,0.844036697247706,0.605063291139241 116,"South Africa",0.666,57.4,13.6,9.9,"12,122",-29,116,0.407,140,50.9,40.7,72.7,75.9,44.5,60.5,0.957839262187088,0.735537190082645 116,"Viet Nam",0.666,75.8,11.9,7.5,"5,092",15,116,0.308,49,29,24.3,59.4,71.2,73,82.2,0.834269662921348,0.888077858880779 119,"Bolivia (Plurinational State of)",0.662,68.3,13.2,8.2,"5,760",4,119,0.444,200,71.9,51.8,47.6,59.1,64.2,80.9,0.805414551607445,0.793572311495674 120,"Kyrgyzstan",0.655,70.6,12.5,10.6,"3,044",29,120,0.353,75,29.3,23.3,94.5,96.8,56,79.5,0.976239669421488,0.70440251572327 121,"Iraq",0.654,69.4,10.1,6.4,"14,003",-44,121,0.539,67,68.7,26.5,27.8,50.2,14.9,69.8,0.553784860557769,0.213467048710602 122,"Cabo Verde",0.646,73.3,13.5,4.7,"6,094",-1,122,NA,53,70.6,20.8,NA,NA,51.5,83.7,NA,0.615292712066906 123,"Micronesia (Federated States of)",0.64,69.1,11.7,9.7,"3,432",21,123,NA,96,18.6,0,NA,NA,NA,NA,NA,NA 124,"Guyana",0.636,66.4,10.3,8.5,"6,522",-4,124,0.515,250,88.5,31.3,60.3,47.8,42.6,80.5,1.26150627615063,0.529192546583851 125,"Nicaragua",0.631,74.9,11.5,6,"4,457",12,125,0.449,100,100.8,39.1,39.4,38.3,47.4,80.3,1.02872062663185,0.590286425902864 126,"Morocco",0.628,74,11.6,4.4,"6,850",-8,126,0.525,120,35.8,11,20.7,30.2,26.5,75.8,0.685430463576159,0.349604221635884 126,"Namibia",0.628,64.8,11.3,6.2,"9,418",-21,126,0.401,130,54.9,37.7,33.3,34.4,54.7,63.7,0.968023255813953,0.858712715855573 128,"Guatemala",0.627,71.8,10.7,5.6,"6,929",-11,128,0.533,140,97.2,13.3,21.9,23.2,49.3,88.2,0.943965517241379,0.558956916099773 129,"Tajikistan",0.624,69.4,11.2,10.4,"2,517",27,129,0.357,44,42.8,15.2,95.1,91.2,58.9,77.1,1.04276315789474,0.763942931258106 130,"India",0.609,68,11.7,5.4,"5,497",-4,130,0.563,190,32.8,12.2,27,56.6,27,79.9,0.477031802120141,0.337922403003755 131,"Honduras",0.606,73.1,11.1,5.5,"3,938",7,131,0.48,120,84,25.8,28,25.8,42.8,82.9,1.08527131782946,0.516284680337756 132,"Bhutan",0.605,69.5,12.6,3,"7,176",-17,132,0.457,120,40.9,8.3,34,34.5,66.7,77.2,0.985507246376812,0.863989637305699 133,"Timor-Leste",0.595,68.2,11.7,4.4,"5,363",-6,133,NA,270,52.2,38.5,NA,NA,24.6,50.8,NA,0.484251968503937 134,"Syrian Arab Republic",0.594,69.6,12.3,6.3,"2,728",21,134,0.533,49,41.6,12.4,29.5,40.5,13.5,72.7,0.728395061728395,0.185694635488308 134,"Vanuatu",0.594,71.9,10.6,6.8,"2,803",19,134,NA,86,44.8,0,NA,NA,61.5,80,NA,0.76875 136,"Congo",0.591,62.3,11.1,6.1,"6,012",-14,136,0.593,410,126.7,11.5,39.7,47,68.5,73,0.84468085106383,0.938356164383562 137,"Kiribati",0.59,66,12.3,7.8,"2,434",21,137,NA,130,16.6,8.7,NA,NA,NA,NA,NA,NA 138,"Equatorial Guinea",0.587,57.6,9,5.5,"21,056",-84,138,NA,290,112.6,19.7,NA,NA,80.7,92.2,NA,0.87527114967462 139,"Zambia",0.586,60.1,13.5,6.6,"3,734",2,139,0.587,280,125.4,12.7,25.8,44,73.1,85.6,0.586363636363636,0.853971962616822 140,"Ghana",0.579,61.4,11.5,7,"3,852",-1,140,0.554,380,58.4,10.9,45.2,64.7,67.3,71.4,0.698608964451314,0.942577030812325 141,"Lao People's Democratic Republic",0.575,66.2,10.6,5,"4,680",-6,141,NA,NA,65,25,22.9,37,76.3,79.1,0.618918918918919,0.964601769911504 142,"Bangladesh",0.57,71.6,10,5.1,"3,191",5,142,0.503,170,80.6,20,34.1,41.3,57.4,84.1,0.825665859564165,0.682520808561237 143,"Cambodia",0.555,68.4,10.9,4.4,"2,949",7,143,0.477,170,44.3,19,9.9,22.9,78.8,86.5,0.432314410480349,0.910982658959538 143,"Sao Tome and Principe",0.555,66.5,11.3,4.7,"2,918",8,143,NA,210,65.1,18.2,NA,NA,45.3,77.8,NA,0.582262210796915 145,"Kenya",0.548,61.6,11,6.3,"2,762",9,145,0.552,400,93.6,20.8,25.3,31.4,62.2,72.4,0.805732484076433,0.859116022099447 145,"Nepal",0.548,69.6,12.4,3.3,"2,311",16,145,0.489,190,73.7,29.5,17.7,38.2,79.9,87.1,0.463350785340314,0.917336394948335 147,"Pakistan",0.538,66.2,7.8,4.7,"4,866",-14,147,0.536,170,27.3,19.7,19.3,46.1,24.6,82.9,0.418655097613883,0.296743063932449 148,"Myanmar",0.536,65.9,8.6,4.1,"4,608",-12,148,0.413,200,12.1,4.7,22.9,15.3,75.2,82.3,1.49673202614379,0.913730255164034 149,"Angola",0.532,52.3,11.4,4.7,"6,822",-30,149,NA,460,170.2,36.8,NA,NA,63.3,76.9,NA,0.823146944083225 150,"Swaziland",0.531,49,11.3,7.1,"5,542",-25,150,0.557,310,72,14.7,21.9,26,43.9,71.6,0.842307692307692,0.613128491620112 151,"Tanzania (United Republic of)",0.521,65,9.2,5.1,"2,411",8,151,0.547,410,122.7,36,5.6,9.5,88.1,90.2,0.589473684210526,0.976718403547672 152,"Nigeria",0.514,52.8,9,5.9,"5,341",-24,152,NA,560,119.6,6.6,NA,NA,48.2,63.7,NA,0.756671899529042 153,"Cameroon",0.512,55.5,10.4,6,"2,803",-1,153,0.587,590,115.8,27.1,21.3,34.9,63.8,76.8,0.610315186246418,0.830729166666667 154,"Madagascar",0.51,65.1,10.3,6,"1,328",24,154,NA,440,122.8,20.5,NA,NA,86.6,90.5,NA,0.956906077348066 155,"Zimbabwe",0.509,57.5,10.9,7.3,"1,615",13,155,0.504,470,60.3,35.1,48.7,62,83.2,89.7,0.785483870967742,0.927536231884058 156,"Mauritania",0.506,63.1,8.5,3.8,"3,560",-14,156,0.61,320,73.3,22.2,8.3,20.9,28.7,79.1,0.397129186602871,0.36283185840708 156,"Solomon Islands",0.506,67.9,9.2,5,"1,540",16,156,NA,130,64.9,2,NA,NA,53.4,79,NA,0.675949367088608 158,"Papua New Guinea",0.505,62.6,9.9,4,"2,463",-1,158,0.611,220,62.1,2.7,7.6,14.5,70.5,74,0.524137931034483,0.952702702702703 159,"Comoros",0.503,63.3,11.5,4.6,"1,456",16,159,NA,350,51.1,3,NA,NA,35.2,80.1,NA,0.439450686641698 160,"Yemen",0.498,63.8,9.2,2.6,"3,519",-17,160,0.744,270,47,0.7,8.6,26.7,25.4,72.2,0.322097378277154,0.35180055401662 161,"Lesotho",0.497,49.8,11.1,5.9,"3,306",-16,161,0.541,490,89.4,26.8,21.9,19,59,73.5,1.15263157894737,0.802721088435374 162,"Togo",0.484,59.7,12.2,4.5,"1,228",17,162,0.588,450,91.5,17.6,16.1,40.3,80.6,81.3,0.399503722084367,0.991389913899139 163,"Haiti",0.483,62.8,8.7,4.9,"1,669",4,163,0.603,380,42,3.5,22.4,35.2,60.9,71,0.636363636363636,0.857746478873239 163,"Rwanda",0.483,64.2,10.3,3.7,"1,458",11,163,0.4,320,33.6,57.5,8,8.8,86.4,85.3,0.909090909090909,1.01289566236811 163,"Uganda",0.483,58.5,9.8,5.4,"1,613",6,163,0.538,360,126.6,35,22.9,33.5,75.8,79.2,0.683582089552239,0.957070707070707 166,"Benin",0.48,59.6,11.1,3.3,"1,767",0,166,0.614,340,90.2,8.4,11.3,27,67.6,78.3,0.418518518518519,0.863346104725415 167,"Sudan",0.479,63.5,7,3.1,"3,809",-27,167,0.591,360,84,23.8,12.1,18.2,31.3,76,0.664835164835165,0.411842105263158 168,"Djibouti",0.47,62,6.4,3.8,"3,276",-22,168,NA,230,18.6,12.7,NA,NA,36.3,67.7,NA,0.536189069423929 169,"South Sudan",0.467,55.7,7.6,5.4,"2,332",-9,169,NA,730,75.3,24.3,NA,NA,NA,NA,NA,NA 170,"Senegal",0.466,66.5,7.9,2.5,"2,188",-8,170,0.528,320,94.4,42.7,7.2,15.4,66,88,0.467532467532468,0.75 171,"Afghanistan",0.465,60.4,9.3,3.2,"1,885",-7,171,0.693,400,86.8,27.6,5.9,29.8,15.8,79.5,0.197986577181208,0.19874213836478 172,"Côte d'Ivoire",0.462,51.5,8.9,4.3,"3,171",-24,172,0.679,720,130.3,9.2,14,30.1,52.4,81.4,0.465116279069767,0.643734643734644 173,"Malawi",0.445,62.8,10.8,4.3,"747",13,173,0.611,510,144.8,16.7,11.1,21.6,84.6,81.5,0.513888888888889,1.03803680981595 174,"Ethiopia",0.442,64.1,8.5,2.4,"1,428",2,174,0.558,420,78.4,25.5,7.8,18.2,78.2,89.3,0.428571428571429,0.875699888017917 175,"Gambia",0.441,60.2,8.8,2.8,"1,507",-2,175,0.622,430,115.8,9.4,17.4,31.5,72.2,82.9,0.552380952380952,0.870928829915561 176,"Congo (Democratic Republic of the)",0.433,58.7,9.8,6,"680",11,176,0.673,730,135.3,8.2,12.8,32.4,70.7,73.2,0.395061728395062,0.965846994535519 177,"Liberia",0.43,60.9,9.5,4.1,"805",7,177,0.651,640,117.4,10.7,15.4,39.3,58.2,64.8,0.391857506361323,0.898148148148148 178,"Guinea-Bissau",0.42,55.2,9,2.8,"1,362",-1,178,NA,560,99.3,13.7,NA,NA,68.2,78.5,NA,0.868789808917197 179,"Mali",0.419,58,8.4,2,"1,583",-8,179,0.677,550,175.6,9.5,7.7,15.1,50.8,81.4,0.509933774834437,0.624078624078624 180,"Mozambique",0.416,55.1,9.3,3.2,"1,123",1,180,0.591,480,137.8,39.6,1.4,6.2,85.5,82.8,0.225806451612903,1.03260869565217 181,"Sierra Leone",0.413,50.9,8.6,3.1,"1,780",-16,181,0.65,1100,100.7,12.4,10,21.7,65.7,69,0.460829493087558,0.952173913043478 182,"Guinea",0.411,58.8,8.7,2.4,"1,096",0,182,NA,650,131,21.9,NA,NA,65.6,78.3,NA,0.837803320561941 183,"Burkina Faso",0.402,58.7,7.8,1.4,"1,591",-13,183,0.631,400,115.4,13.3,0.9,3.2,77.1,90,0.28125,0.856666666666667 184,"Burundi",0.4,56.7,10.1,2.7,"758",1,184,0.492,740,30.3,34.9,5.3,8.3,83.3,82,0.63855421686747,1.01585365853659 185,"Chad",0.392,51.6,7.4,1.9,"2,085",-22,185,0.706,980,152,14.9,1.7,9.9,64,79.2,0.171717171717172,0.808080808080808 186,"Eritrea",0.391,63.7,4.1,3.9,"1,130",-6,186,NA,380,65.3,22,NA,NA,80,89.8,NA,0.89086859688196 187,"Central African Republic",0.35,50.7,7.2,4.2,"581",1,187,0.655,880,98.3,12.5,10.1,26.7,72.6,85.1,0.378277153558052,0.853113983548766 188,"Niger",0.348,61.4,5.4,1.5,"908",-5,188,0.713,630,204.8,13.3,2.4,7.8,40,89.7,0.307692307692308,0.445930880713489 NA,"Arab States",0.686,70.6,12,6.4,"15,722",NA,NA,0.537,155,45.4,14,34.7,47.6,23.2,75.3,0.728991596638656,0.308100929614874 NA,"East Asia and the Pacific",0.71,74,12.7,7.5,"11,449",NA,NA,0.328,72,21.2,18.7,54.7,66.3,62.6,79.4,0.825037707390649,0.788413098236776 NA,"Europe and Central Asia",0.748,72.3,13.6,10,"12,791",NA,NA,0.3,28,30.8,19,70.8,80.6,45.6,70,0.878411910669975,0.651428571428571 NA,"Latin America and the Caribbean",0.748,75,14,8.2,"14,242",NA,NA,0.415,85,68.3,27,54.3,55.2,53.7,79.8,0.983695652173913,0.672932330827068 NA,"South Asia",0.607,68.4,11.2,5.5,"5,605",NA,NA,0.536,183,38.7,17.5,29.1,54.6,29.8,80.3,0.532967032967033,0.371108343711083 NA,"Sub-Saharan Africa",0.518,58.5,9.6,5.2,"3,363",NA,NA,0.575,506,109.7,22.5,22.1,31.5,65.4,76.6,0.701587301587302,0.85378590078329 NA,"World",0.711,71.5,12.2,7.9,"14,301",NA,NA,0.449,210,47.4,21.8,54.5,65.4,50.3,76.7,0.833333333333333,0.655801825293351

tidyr package and human are available

access the stringr package

library(stringr)

look at the structure of the GNI column in 'human'

str(human$GNI)

remove the commas from GNI and print out a numeric version of it

str_replace(human$GNI, pattern=",", replace ="") %>% as.numeric

human with modified GNI and dplyr are available

columns to keep

keep <- c("Country", "Edu2.FM", "Labo.FM", "Life.Exp", "Edu.Exp", "GNI", "Mat.Mor", "Ado.Birth", "Parli.F")

select the 'keep' columns

human <- select(human, one_of(keep))

print out a completeness indicator of the 'human' data

complete.cases(human)

print out the data along with a completeness indicator as the last column

data.frame(human[-1], comp = complete.cases(human))

filter out all rows with NA values

human_ <- filter(human, complete.cases(human))

output: pdf_document: default html_document: default

continue to be amazed

I did finally realized that the editing and commiting was in the github not in RStudio, I was desperate even though I was trying to understand, I hope this will begin to be simple now.

  • I installed R, then RStudio and finally Git, I created an account and tried to update my profile.
  • I learned how to execute some data camp stuff.
  • I could say that this project is designated to people who would like to share their project to public so that others can use them also or for team work so that they can share and edit together a specific project.
date()

Let's learn more this week...

human with modified GNI and dplyr are available

columns to keep

keep <- c("Country", "Edu2.FM", "Labo.FM", "Life.Exp", "Edu.Exp", "GNI", "Mat.Mor", "Ado.Birth", "Parli.F")

select the 'keep' columns

human <- select(human, one_of(keep))

print out a completeness indicator of the 'human' data

complete.cases(human)

print out the data along with a completeness indicator as the last column

data.frame(human[-1], comp = complete.cases(human))

filter out all rows with NA values

human_ <- filter(human, complete.cases(human))

`# human without NA is available

look at the last 10 observations

tail(human, 10)

last indice we want to keep

last <- nrow(human) - 7

choose everything until the last 7 observations

human_ <- human[1:last, ]

add countries as rownames

rownames(human) <- human$Country ``{r}

# The data BPRS is available

# Access the packages dplyr and tidyr
library(dplyr)
library(tidyr)

# Factor treatment & subject
BPRS$treatment <- factor(BPRS$treatment)
BPRS$subject <- factor(BPRS$subject)

# Convert to long form
BPRSL <-  BPRS %>% gather(key = weeks, value = bprs, -treatment, -subject)

# Extract the week number
BPRSL <-  BPRSL %>% mutate(week = as.integer(substr(weeks,5,5)))

# Take a glimpse at the BPRSL data
glimpse(BPRSL)
# The data BPRS is available
# Access the packages dplyr and tidyr
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(tidyr)
# Factor treatment & subject
BPRS$treatment <- factor(BPRS$treatment)
BPRS$subject <- factor(BPRS$subject)
# Convert to long form
BPRSL <-  BPRS %>% gather(key = weeks, value = bprs, -treatment, -subject)
# Extract the week number
BPRSL <-  BPRSL %>% mutate(week = as.integer(substr(weeks,5,5)))
# Take a glimpse at the BPRSL data
glimpse(BPRSL)
Observations: 360
Variables: 5
$ treatment <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
$ subject   <fct> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17...
$ weeks     <chr> "week0", "week0", "week0", "week0", "week0", "week0", "we...
$ bprs      <int> 42, 58, 54, 55, 72, 48, 71, 30, 41, 57, 30, 55, 36, 38, 6...
$ week      <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
# dplyr, tidyr packages and BPRSL are available

#Access the package ggplot2
library(ggplot2)

# Draw the plot
ggplot(BPRSL, aes(x = week, y = bprs, linetype = subject)) +
  geom_line() +
  scale_linetype_manual(values = rep(1:10, times=4)) +
  facet_grid(. ~ treatment, labeller = label_both) +
  theme(legend.position = "none") + 
  scale_y_continuous(limits = c(min(BPRSL$bprs), max(BPRSL$bprs)))
  # dplyr, tidyr and ggplot2 packages and BPRSL are available

# Standardise the variable bprs
BPRSL <- BPRSL %>%
  group_by(week) %>%
  mutate(stdbprs = (bprs - mean(bprs))/sd(bprs) ) %>%
  ungroup()

# Glimpse the data
glimpse(BPRSL)

# Plot again with the standardised bprs
ggplot(BPRSL, aes(x = week, y = stdbprs, linetype = subject)) +
  geom_line() +
  scale_linetype_manual(values = rep(1:10, times=4)) +
  facet_grid(. ~ treatment, labeller = label_both) +
  scale_y_continuous(name = "standardized bprs")
  # dplyr, tidyr & ggplot2 packages and BPRSL are available

# Number of weeks, baseline (week 0) included
n <- BPRSL$week %>% unique() %>% length()

# Summary data with mean and standard error of bprs by treatment and week 
BPRSS <- BPRSL %>%
  group_by(treatment, week) %>%
  summarise( mean = mean(bprs), se = sd(bprs)/sqrt(n) ) %>%
  ungroup()

# Glimpse the data
glimpse(BPRSS)

# Plot the mean profiles
ggplot(BPRSS, aes(x = week, y = mean, linetype = treatment, shape = treatment)) +
  geom_line() +
  scale_linetype_manual(values = c(1,2)) +
  geom_point(size=3) +
  scale_shape_manual(values = c(1,2)) +
  geom_errorbar(aes(ymin = mean - se, ymax = mean + se, linetype="1"), width=0.3) +
  theme(legend.position = c(0.8,0.8)) +
  scale_y_continuous(name = "mean(bprs) +/- se(bprs)")
  # dplyr, tidyr & ggplot2 packages and BPRSL are available

# Create a summary data by treatment and subject with mean as the summary variable (ignoring baseline week 0).
BPRSL8S <- BPRSL %>%
  filter(week > 0) %>%
  group_by(treatment, subject) %>%
  summarise( mean=mean(bprs) ) %>%
  ungroup()

# Glimpse the data
glimpse(BPRSL8S)

# Draw a boxplot of the mean versus treatment
ggplot(BPRSL8S, aes(x = treatment, y = mean)) +
  geom_boxplot() +
  stat_summary(fun.y = "mean", geom = "point", shape=23, size=4, fill = "white") +
  scale_y_continuous(name = "mean(bprs), weeks 1-8")

# Create a new data by filtering the outlier and adjust the ggplot code the draw the plot again with the new data
BPRSL8S1 <- BPRSL8S %>%
  filter(mean < 60)
  # dplyr is available

# read the RATS data
RATS <- read.table("https://raw.githubusercontent.com/KimmoVehkalahti/MABS/master/Examples/data/rats.txt", header = TRUE, sep = '\t')

# Factor variables ID and Group
RATS$ID <- factor(RATS$ID)
RATS$Group <- factor(RATS$Group)

# Glimpse the data
glimpse(RATS)
# dplyr, tidyr and RATS are available

# Convert data to long form
RATSL <- RATS %>%
  gather(key = WD, value = Weight, -ID, -Group) %>%
  mutate(Time = as.integer(substr(WD,3,4))) 

# Glimpse the data
glimpse(RATSL)
# dplyr, tidyr and RATSL are available

# Check the dimensions of the data
dim(RATSL)

# Plot the RATSL data
ggplot(RATSL, aes(x = Time, y = Weight, group = ID)) +
  geom_line(aes(linetype = Group)) +
  scale_x_continuous(name = "Time (days)", breaks = seq(0, 60, 10)) +
  scale_y_continuous(name = "Weight (grams)") +
  theme(legend.position = "top")
  # dplyr, tidyr and RATSL are available

# Check the dimensions of the data
dim(RATSL)

# Plot the RATSL data
ggplot(RATSL, aes(x = Time, y = Weight, group = ID)) +
  geom_line(aes(linetype = Group)) +
  scale_x_continuous(name = "Time (days)", breaks = seq(0, 60, 10)) +
  scale_y_continuous(name = "Weight (grams)") +
  theme(legend.position = "top")

About

Template for the IODS course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 99.2%
  • Rebol 0.8%