Making a map using IELTS Averages in Asia
[This article was first published on Home on educatorsRlearners: A blog about education and R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
library(tidyverse) ## ── Attaching packages ──────────────────────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ── ## ✔ ggplot2 3.1.0 ✔ purrr 0.3.0 ## ✔ tibble 2.0.1 ✔ dplyr 0.8.0.1 ## ✔ tidyr 0.8.2 ✔ stringr 1.4.0 ## ✔ readr 1.3.1 ✔ forcats 0.4.0 ## ── Conflicts ─────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ── ## ✖ dplyr::filter() masks stats::filter() ## ✖ dplyr::lag() masks stats::lag() library(spData) library(spDataLarge) library(rvest) ## Loading required package: xml2 ## ## Attaching package: 'rvest' ## The following object is masked from 'package:purrr': ## ## pluck ## The following object is masked from 'package:readr': ## ## guess_encoding library(tmap) world %>% filter(subregion %in% c("Eastern Asia", "South-Eastern Asia")) -> east_asia tm_shape(east_asia, projection = 3857) + tm_polygons(col = "lifeExp", n = 5) + tm_layout(title = "EAAST",inner.margins = c(0.1, 0.02, 0.05, 0.02)) + tm_scale_bar()
#loads the website ielts.org <- read_html("https://www.ielts.org/teaching-and-research/test-taker-performance") #print out all the tables on that page ielts.org %>% html_table() ## [[1]] ## X1 X2 ## 1 2017 ## 2 Academic 78.10% ## 3 General Training 21.9% ## ## [[2]] ## X1 X2 X3 X4 X5 X6 ## 1 Gender Listening Reading Writing Speaking Overall ## 2 Female 6.26 6.18 5.66 5.97 6.08 ## 3 Male 6.17 6.02 5.55 5.88 5.97 ## ## [[3]] ## X1 X2 X3 X4 X5 X6 ## 1 Gender Listening Reading Writing Speaking Overall ## 2 Female 6.66 6.27 6.15 6.62 6.49 ## 3 Male 6.62 6.25 6.05 6.57 6.44 ## ## [[4]] ## X1 X2 X3 X4 X5 X6 ## 1 Listening Reading Writing Speaking Overall ## 2 Bangladesh 6.37 6.02 5.83 6.25 6.18 ## 3 Brazil 6.74 6.91 5.98 6.72 6.65 ## 4 Canada 7.09 6.78 6.16 7.15 6.86 ## 5 China (People's Republic of) 5.90 6.11 5.37 5.39 5.76 ## 6 Colombia 6.35 6.72 5.78 6.49 6.40 ## 7 Egypt 6.74 6.43 5.87 6.46 6.44 ## 8 France 6.95 7.04 6.02 6.56 6.71 ## 9 Germany 7.76 7.52 6.60 7.36 7.37 ## 10 Greece 7.43 7.16 6.27 6.76 6.97 ## 11 Hong Kong 6.90 6.76 5.97 6.25 6.53 ## 12 India 6.30 5.82 5.77 6.01 6.04 ## 13 Indonesia 6.55 6.67 5.78 6.27 6.38 ## 14 Iran, Islamic Republic of 6.24 5.98 5.58 6.43 6.12 ## 15 Iraq 5.54 5.44 5.13 5.86 5.56 ## 16 Italy 6.83 7.20 5.99 6.54 6.70 ## 17 Japan 5.91 6.09 5.41 5.59 5.81 ## 18 Jordan 6.27 5.89 5.47 6.35 6.06 ## 19 Kazakhstan 6.17 6.16 5.57 5.91 6.01 ## 20 Korea, Republic of 6.20 6.20 5.46 5.79 5.97 ## 21 Kuwait 5.47 5.08 4.84 5.79 5.36 ## 22 Malaysia 7.27 7.07 6.25 6.71 6.89 ## 23 Mexico 6.54 6.78 5.81 6.54 6.48 ## 24 Nepal 6.27 5.75 5.56 5.81 5.91 ## 25 Nigeria 6.82 6.46 6.51 7.11 6.79 ## 26 Oman 5.11 4.98 4.90 5.62 5.22 ## 27 Pakistan 6.57 6.20 5.95 6.43 6.35 ## 28 Philippines 7.27 6.80 6.20 6.85 6.84 ## 29 Romania 7.03 6.89 6.12 6.78 6.77 ## 30 Russian Federation 6.93 6.91 5.99 6.67 6.69 ## 31 Saudi Arabia 5.26 5.05 4.78 5.69 5.26 ## 32 Spain 7.02 7.16 6.11 6.71 6.81 ## 33 Sri Lanka 6.60 6.15 5.90 6.49 6.35 ## 34 Sudan 6.43 6.10 5.68 6.41 6.22 ## 35 Taiwan, China 6.16 6.21 5.60 6.08 6.08 ## 36 Thailand 6.25 6.03 5.46 5.91 5.98 ## 37 Turkey 6.40 6.42 5.69 6.21 6.24 ## 38 Ukraine 6.65 6.58 5.94 6.49 6.48 ## 39 United Arab Emirates 4.88 4.70 4.48 5.27 4.90 ## 40 Uzbekistan 5.63 5.63 5.27 5.61 5.60 ## 41 Vietnam 5.97 6.17 5.59 5.71 5.92 ## ## [[5]] ## X1 X2 X3 X4 X5 X6 ## 1 Listening Reading Writing Speaking Overall ## 2 Australia 7.32 6.92 6.44 7.55 7.12 ## 3 Bangladesh 6.47 6.01 6.05 6.48 6.32 ## 4 Brazil 6.68 6.76 6.11 6.72 6.63 ## 5 Canada 7.10 6.79 6.28 7.15 6.89 ## 6 China (People's Republic of) 6.06 6.03 5.61 5.74 5.93 ## 7 Colombia 6.09 6.17 5.79 6.33 6.16 ## 8 Egypt 6.67 6.35 5.96 6.52 6.44 ## 9 France 6.91 6.83 6.15 6.83 6.74 ## 10 Germany 7.22 6.91 6.40 7.38 7.04 ## 11 Hong Kong 6.65 6.59 5.93 6.28 6.42 ## 12 India 6.86 6.34 6.22 6.68 6.59 ## 13 Indonesia 6.08 5.84 5.59 6.02 5.95 ## 14 Iran, Islamic Republic of 6.38 6.06 5.81 6.53 6.26 ## 15 Italy 6.28 6.09 5.68 6.40 6.17 ## 16 Japan 5.86 5.53 5.39 5.71 5.68 ## 17 Jordan 6.42 6.03 5.75 6.60 6.26 ## 18 Korea, Republic of 5.89 5.53 5.39 5.63 5.67 ## 19 Lebanon 6.80 6.41 6.05 6.73 6.56 ## 20 Malaysia 7.11 6.89 6.31 6.87 6.86 ## 21 Mexico 6.36 6.38 5.91 6.63 6.38 ## 22 Nepal 6.32 5.67 5.79 6.23 6.07 ## 23 Nigeria 6.77 6.38 6.80 7.22 6.85 ## 24 Pakistan 6.75 6.28 6.21 6.75 6.56 ## 25 Philippines 6.46 5.99 5.98 6.46 6.29 ## 26 Poland 6.83 6.64 6.13 6.82 6.67 ## 27 Russian Federation 6.90 6.88 6.13 6.68 6.71 ## 28 Saudi Arabia 4.78 3.90 4.39 5.17 4.63 ## 29 Singapore 7.71 7.49 6.78 7.48 7.43 ## 30 South Africa 7.66 7.27 7.00 8.26 7.61 ## 31 Spain 6.61 6.80 6.05 6.56 6.56 ## 32 Sri Lanka 6.69 6.20 6.06 6.65 6.46 ## 33 Sudan 6.31 5.84 5.80 6.55 6.19 ## 34 Syrian Arab Republic 6.36 6.02 5.73 6.60 6.25 ## 35 Taiwan, China 5.98 5.61 5.55 6.05 5.86 ## 36 Thailand 5.37 4.83 5.06 5.45 5.24 ## 37 Turkey 6.50 6.42 5.98 6.46 6.40 ## 38 Ukraine 6.25 6.10 5.83 6.29 6.18 ## 39 United States of America 7.92 7.67 7.48 8.44 7.95 ## 40 Vietnam 6.16 6.12 5.83 6.00 6.09 ## 41 Zimbabwe 7.15 6.78 6.84 7.55 7.14 ## ## [[6]] ## X1 X2 X3 X4 X5 X6 ## 1 Language Listening Reading Writing Speaking Overall ## 2 Arabic 5.63 5.37 5.06 5.88 5.55 ## 3 Azeri 6.42 6.16 5.58 6.12 6.14 ## 4 Bengali 6.45 6.11 5.88 6.31 6.25 ## 5 Chinese 5.97 6.15 5.41 5.46 5.81 ## 6 English 7.21 6.71 6.35 7.14 6.92 ## 7 Farsi 6.29 6.03 5.61 6.47 6.16 ## 8 Filipino 7.31 6.86 6.22 6.87 6.88 ## 9 French 6.91 6.95 6.03 6.59 6.68 ## 10 German 7.80 7.55 6.62 7.39 7.41 ## 11 Greek 7.35 7.03 6.24 6.73 6.90 ## 12 Gujarati 6.18 5.71 5.63 5.86 5.91 ## 13 Hindi 6.67 6.13 5.94 6.37 6.34 ## 14 Ibo/lgbo 6.60 6.27 6.47 7.09 6.67 ## 15 Indonesian 6.54 6.67 5.78 6.26 6.37 ## 16 Italian 6.83 7.22 5.99 6.53 6.70 ## 17 Japanese 5.90 6.09 5.41 5.59 5.81 ## 18 Kazakh 6.06 6.04 5.51 5.81 5.92 ## 19 Khmer 5.92 5.73 5.48 5.92 5.82 ## 20 Korean 6.20 6.21 5.46 5.79 5.98 ## 21 Malay 7.03 6.86 6.07 6.54 6.69 ## 22 Malayalam 6.73 6.34 6.10 6.39 6.45 ## 23 Marathi 7.06 6.49 6.23 6.69 6.68 ## 24 Nepali 6.28 5.75 5.56 5.82 5.92 ## 25 Other 6.60 6.29 6.18 6.96 6.57 ## 26 Polish 7.36 7.25 6.29 6.99 7.03 ## 27 Portuguese 6.86 6.94 6.04 6.80 6.72 ## 28 Punjabi 5.92 5.47 5.56 5.67 5.72 ## 29 Romanian 7.01 6.89 6.12 6.79 6.77 ## 30 Russian 6.74 6.71 5.89 6.52 6.53 ## 31 Singhalese 6.58 6.14 5.89 6.46 6.33 ## 32 Spanish 6.65 6.89 5.93 6.62 6.59 ## 33 Tagalog 7.17 6.68 6.14 6.80 6.76 ## 34 Tamil 6.86 6.41 6.05 6.54 6.53 ## 35 Telugu 6.34 5.80 5.75 6.08 6.05 ## 36 Thai 6.24 6.03 5.46 5.90 5.97 ## 37 Turkish 6.42 6.42 5.70 6.22 6.25 ## 38 Ukrainian 6.62 6.57 5.94 6.48 6.47 ## 39 Urdu 6.61 6.21 5.97 6.47 6.38 ## 40 Uzbek 5.57 5.56 5.23 5.55 5.54 ## 41 Vietnamese 5.97 6.17 5.59 5.71 5.93 ## ## [[7]] ## X1 X2 X3 X4 X5 X6 ## 1 Language Listening Reading Writing Speaking Overall ## 2 Afrikaans 7.38 6.97 6.73 7.95 7.32 ## 3 Albanian 5.92 5.57 5.93 6.47 6.03 ## 4 Arabic 6.18 5.75 5.62 6.31 6.03 ## 5 Bengali 6.62 6.19 6.16 6.60 6.46 ## 6 Chinese 6.13 6.08 5.65 5.83 5.99 ## 7 English 7.26 6.82 6.71 7.40 7.11 ## 8 Farsi 6.39 6.07 5.82 6.54 6.27 ## 9 Filipino 6.57 6.12 6.05 6.53 6.38 ## 10 French 6.48 6.35 6.05 6.63 6.44 ## 11 German 7.25 6.95 6.42 7.39 7.06 ## 12 Gujurati 6.55 6.02 5.95 6.33 6.28 ## 13 Hindi 7.07 6.57 6.37 6.90 6.79 ## 14 Ibo/lgbo 6.60 6.18 6.73 7.19 6.74 ## 15 Indonesian 6.07 5.84 5.59 6.01 5.95 ## 16 Italian 6.33 6.17 5.71 6.44 6.23 ## 17 Japanese 5.85 5.53 5.38 5.70 5.67 ## 18 Kannada 6.98 6.50 6.42 6.91 6.76 ## 19 Korean 5.89 5.53 5.39 5.63 5.67 ## 20 Malayalam 6.87 6.47 6.25 6.62 6.62 ## 21 Marathi 7.09 6.67 6.44 6.95 6.85 ## 22 Nepali 6.34 5.69 5.80 6.24 6.08 ## 23 Other 6.56 6.14 6.48 7.07 6.63 ## 24 Pashto 6.37 5.85 5.93 6.54 6.24 ## 25 Polish 6.84 6.64 6.13 6.82 6.67 ## 26 Portuguese 6.70 6.75 6.11 6.74 6.64 ## 27 Punjabi 6.46 5.83 5.88 6.22 6.16 ## 28 Romanian 6.73 6.60 6.11 6.74 6.61 ## 29 Russian 6.75 6.70 6.08 6.62 6.60 ## 30 Shona 7.07 6.72 6.79 7.45 7.07 ## 31 Singhalese 6.67 6.18 6.04 6.62 6.44 ## 32 Spanish 6.37 6.43 5.95 6.55 6.39 ## 33 Tagalog 6.31 5.82 5.89 6.35 6.15 ## 34 Tamil 6.79 6.37 6.20 6.65 6.57 ## 35 Telugu 6.75 6.24 6.18 6.64 6.52 ## 36 Thai 5.36 4.83 5.06 5.45 5.24 ## 37 Turkish 6.50 6.42 5.98 6.46 6.40 ## 38 Ukrainian 6.15 5.93 5.76 6.23 6.08 ## 39 Urdu 6.78 6.30 6.22 6.77 6.58 ## 40 Vietnamese 6.16 6.13 5.84 6.00 6.10 ## 41 Yoruba 6.62 6.31 6.76 7.09 6.76 #select the table of interest ielts.org %>% html_node(xpath = '//*[@id="main"]/div/div/div[2]/table[3]') %>% html_table(header = TRUE) -> scores_by_country #Change Korea, China, and Taiwan so that they merge correctly scores_by_country[scores_by_country == "Korea, Republic of"] <- "Republic of Korea" scores_by_country[scores_by_country == "China (People's Republic of)"] <- "China" scores_by_country[scores_by_country == "Taiwan, China"] <- "Taiwan" #name the first colunn names(scores_by_country)[1] <- "name_long" world_scores <- full_join(x = world, y = scores_by_country) ## Joining, by = "name_long" world_scores %>% filter(subregion %in% c("Eastern Asia", "South-Eastern Asia")) -> east_asia_scores tm_shape(east_asia_scores, projection = 3857) + tm_polygons(col = "Speaking", n = 4) + tm_layout(title = "Average IELTS Speaking Score", inner.margins = c(0.1, 0.02, 0.1, 0.02))
tm_shape(east_asia_scores, projection = 3857) + tm_polygons(col = "Writing", n = 3) + tm_layout(title = "Average IELTS Writing Score", inner.margins = c(0.1, 0.02, 0.1, 0.02))
tm_shape(east_asia_scores, projection = 3857) + tm_polygons(col = "Listening", n = 3) + tm_layout(title = "Average IELTS Listening Score", inner.margins = c(0.1, 0.02, 0.1, 0.02))
tm_shape(east_asia_scores, projection = 3857) + tm_polygons(col = "Reading", n = 3) + tm_layout(title = "Average IELTS Reading Score", inner.margins = c(0.1, 0.02, 0.1, 0.02))
To leave a comment for the author, please follow the link and comment on their blog: Home on educatorsRlearners: A blog about education and R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.