-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapping-global-talent-competitiveness.R
More file actions
61 lines (46 loc) · 1.02 KB
/
mapping-global-talent-competitiveness.R
File metadata and controls
61 lines (46 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#=================
# INSTALL PACKAGES
#=================
library(tidyverse)
library(rvest)
library(magrittr)
library(ggmap)
library(stringr)
#============
# SCRAPE DATA
#============
html.global_talent <- read_html("https://www.insead.edu/news/2017-global-talent-competitiveness-index-davos")
#===========
# CLEAN DATA
#===========
clean_data <- function(tableN) {
# global talent countries
df.RAW <- html.global_talent %>%
html_nodes("table") %>%
.[[tableN]] %>%
html_table()
# split df in 2
df1 <- df.RAW %>%
select(X1, X2) %>%
rename(rank = X1,
country = X2)
df2 <- df.RAW %>%
select(X3, X4) %>%
rename(rank = X3,
country = X4)
# combine splits
df <- rbind(df1, df2)
df
}
# get top countries
df.global_talent_countries <- clean_data(1)
# inspect
df.global_talent_countries
# get top cities
df.global_talent_cities <- clean_data(2)
# inspect
df.global_talent_cities
#==============
# GET WORLD MAP
#==============
map.world <- map_data("world")