<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/one-thing-critical-for-success-in-the-age-of-ai-and-who-has-it/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://sharpsightlabs.com/blog/human-capital-map/"> r-bloggers – SHARP SIGHT LABS</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a href="http://sharpsightlabs.com/join-newsletter-rapid-mastery/"><br>
<img sizes="(max-width: 1588px) 100vw, 1588px" alt="" class="wp-image-3043" src="https://i2.wp.com/sharpsightlabs.com/wp-content/uploads/2017/02/human-capital-index_v1.png?resize=456%2C261" data-recalc-dims="1"><br>
</a></p>
<p>Data science, artificial intelligence, automation, and other advanced technologies are reshaping the world.</p>
<p>We’re starting to see glimpses of it, for example the rapid emergence of self driving cars. Moreover, the changes brought about by technology will likely become more frequent and more dramatic in the next few years.</p>
<p>In fact, two MIT economist, Erik Brynjolfsson and Andrew McAfee, think that the emergence of AI and data driven technologies may be one of the <a target="_blank" rel="nofollow" href="http://sharpsightlabs.com/blog/second-machine-age-welcome/">most important events in all of human history</a>. </p>
<h3>Risk and opportunity in the age of AI</h3>
<p>They suggest that AI and automation will dramatically increase productivity and human development. In essence, AI, <a target="_blank" rel="nofollow" href="http://sharpsightlabs.com/blog/machine-learning-google-rethink/">machine learning</a>, and data-driven technology will free us from our cognitive limitations much like the engine freed us from our physical limitations. This will in turn lead to large gains in productivity.</p>
<p>But while AI and data-driven tech will likely increase productivity, they are also likely to lead to high levels of unemployment. As software and technology become more intelligent, they will replace people who don’t have the right skills.</p>
<h3>A critical factor for success: human capital</h3>
<p>How can someone succeed in such an era?</p>
<p>Brynjolfsson and McAfee point out that one of the keys to success in the age of data, AI, and automation will be <em>human capital</em>.</p>
<p>As technology increasingly substitutes for people, one of the keys to success will be cutting-edge knowledge, judgement (particularly in complex domains), and creativity.</p>
<h1>Mapping Human Capital</h1>
<p>In thinking about this, I decided to map which countries have the highest levels of human capital, as measured by the World Economic Forum.</p>
<p>While the WEF’s <em>Human Capital Index</em> is not a perfect index of cutting edge skill, it does provide a high-level view of the countries that may be better prepared for a changing, high-tech world.</p>
<p>One thing in particular that I’ll note, is that this map effectively shows <em>averages</em> of national performance. Having said that, talent and innovation are known to be highly uneven geographically. There are “spikes.” So even though this map shows countries’ average performance, we’d likely see an even different story if we looked at cities (or even zip codes).</p>
<h2>R Code: mapping human capital</h2>
<p>The following R code generates a map of the WEF’s Human Capital Index.</p>
<p>The data are scraped from the WEF and then joined to a map of the world generated by the  function. </p>
<p>Pay close attention to the join itself. The join was a little tricky, because the country names in the WEF data were not all identical to the names in the world map. Specifically, I had to first identify the countries that <em>did not</em> match, and then recode them. </p>
<h2>R code</h2>
<pre class="wp-code-highlight">
#==============
# LOAD PACKAGES
#==============
library(tidyverse)
library(stringr)
library(readr)
library(rvest)
library(viridis)


#============
# SCRAPE DATA
#============

#-----------------------
# ESTABLISH URL LOCATION
#-----------------------
html.human_capital &lt;- read_html(&quot;http://reports.weforum.org/human-capital-report-2016/rankings/&quot;)


#-------------------------------
# SCRAPE: Extract table from URL
#-------------------------------
df.human_capital &lt;- html.human_capital %>%
                        html_node(&quot;table&quot;) %>%
                        html_table()


# inspect
glimpse(df.human_capital)



#========================
# RENAME VARIABLES
# - convert to lower case
#========================

df.human_capital &lt;- df.human_capital %>%
                        rename(rank = `Overall Rank`
                               ,country_nm = Economy
                               ,human_cap_score = `Overall Score`
                               )



# INSPECT
glimpse(df.human_capital)


#==============
# GET WORLD MAP
#==============

map.world &lt;- map_data(&quot;world&quot;)

# INSPECT
glimpse(map.world)




#===================================================================
# RECODE COUNTRY NAMES
#  some of the countries in the data frame df.human_capital don't 
#  exactly match the names in map.world.
#  This prohibits a proper join.  
#  We're going to hard-code (i.e. recode) these values to make sure
#  that the join works properly
#===================================================================

#------------------------------------------
# GET LIST OF COUNTRIES IN df.human_capital
#------------------------------------------
df.hcap_countries &lt;- df.human_capital %>% 
  select(country_nm)


#-----------------------------------
# GET LIST OF COUNTRIES IN map.world
#-----------------------------------
df.map_countries &lt;- map.world %>%
  select(region) %>% 
  group_by(region) %>%
  summarise(match = 1) 


#-----------------------------
# LOOK FOR MATCH or NO-MATCH
#  - we'll use a join for this
#    and inspect the output
#-----------------------------

df.check_match &lt;- left_join(df.hcap_countries, df.map_countries, by = c('country_nm' = 'region'))

df.check_match %>%
  filter(is.na(match))


#------------------------------
# THESE ARE THE COUNTRIES THAT
# DO NOT MATCH:
#             country_nm  match
# 1   Russian Federation     NA
# 2       United Kingdom     NA
# 3        United States     NA
# 4           Korea Rep.     NA
# 5      Kyrgyz Republic     NA
# 6      Slovak Republic     NA
# 7        Macedonia FYR     NA
# 8    Iran Islamic Rep.     NA
# 9  Trinidad and Tobago     NA
# 10             Lao PDR     NA
# 11       CÙte d’Ivoire     NA
#------------------------------


#---------------------------------------------------------
# RECODE COUNTRY NAMES
#  - now that we have the names from df.human_capital that
#    don't match map.world, we can recode them
#  - to get the &quot;new&quot; names that we need to use,
#    inspect the names in df.map_countries
#---------------------------------------------------------

df.human_capital$country_nm &lt;- recode(df.human_capital$country_nm
                                       ,'Russian Federation'    = 'Russia'
                                       ,'United Kingdom'        = 'UK'
                                       ,'United States'         = 'USA'
                                       ,'Korea, Rep.'           = 'South Korea'
                                       ,'Kyrgyz Republic'       = 'Kyrgyzstan'
                                       ,'Slovak Republic'       = 'Slovakia'
                                       ,'Macedonia, FYR'        = 'Macedonia'
                                       ,'Iran, Islamic Rep.'    = 'Iran'
                                       ,'Trinidad and Tobago'   = 'Trinidad'
                                       ,'Lao PDR'               = 'Laos'
                                       ,'CÙte d’Ivoire'         = 'Ivory Coast'
                                       )



#====================================================
# JOIN HUMAN CAPITAL DATA TO MAP
# - now we can join the human capital data to the map
#====================================================

map.world &lt;- left_join(map.world, df.human_capital, by = c('region' = 'country_nm'))

glimpse(map.world)


#=====================================
# PLOT: BASIC MAP
# - this is a simple first iteration
#=====================================
ggplot(data = map.world, aes(x = long, y = lat, group = group)) +
  geom_polygon(aes(fill = human_cap_score)) 



#=======================================
# PLOT FINAL MAP
# - this is the finalized version after 
#   much iteration
#=======================================


ggplot(data = map.world, aes(x = long, y = lat, group = group)) +
  geom_polygon(aes(fill = human_cap_score)) +
  scale_fill_viridis(name = &quot;Human Capital\nIndex&quot;) +
  labs(title = &quot;Human Capital Index, by country&quot;
       ,subtitle = &quot;source: World Economic Forum, 2016\n            reports.weforum.org/human-capital-report-2016/&quot;) +
  theme(panel.background = element_rect(fill = &quot;#3E3E3E&quot;)
        ,plot.background = element_rect(fill = &quot;#3E3E3E&quot;)
        ,legend.background = element_blank()
        ,axis.title = element_blank()
        ,axis.text = element_blank()
        ,axis.ticks = element_blank()
        ,panel.grid = element_blank()
        ,text = element_text(family = &quot;Gill Sans&quot;, color = &quot;#DDDDDD&quot;)
        ,plot.title = element_text(size = 32)
        ,legend.position = c(.18,.375)
        ) 

</pre>
<h1>Sign up to learn data science</h1>
<p>People who know data science and machine learning will have massive opportunities in the age of AI and data-driven tech.</p>
<p><a href="http://sharpsightlabs.com/join-newsletter-rapid-mastery/"><strong>Sign up now</strong></a> to get our free <em>Data Science Crash Course</em>, where you’ll learn:</p>
<ul>
<li>a step-by-step data science learning plan </li>
<li>the 1 programming language you need to learn </li>
<li>3 essential data visualizations</li>
<li>how to do data manipulation in R</li>
<li>how to get started with machine learning</li>
<li>and more …</li>
</ul>
<p><a href="http://sharpsightlabs.com/join-newsletter-rapid-mastery/">
<p><strong>SIGN UP NOW</strong></p>
<p></p></a>
<p>The post <a target="_blank" rel="nofollow" href="http://sharpsightlabs.com/blog/human-capital-map/">One thing critical for success in the age of AI (and who has it)</a> appeared first on <a target="_blank" rel="nofollow" href="http://sharpsightlabs.com/">SHARP SIGHT LABS</a>.</p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://sharpsightlabs.com/blog/human-capital-map/"> r-bloggers – SHARP SIGHT LABS</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/3Yg-rzCo1lc"></a></div>