Watch Above Video for atleast more than 30 seconds to see all the moving effects.

Watch Above Video for atleast more than 30 seconds to see all the moving effects.

McDonald’s ( MCD ) and Burger King (which is operated by Restaurant Brands International (RBI) ( QSR )) , compete closely with each other in the fast food segment. However with its much bigger size and larger market share ( 19% vs. 5% according to recent estimates ), McDonald’s is clearly the leader. A couple of years ago, it appeared that Burger King was threatening McDonald’s after it was taken over by Restaurant Brands International (RBI) which pursued an aggressive expansion strategy and focused on cutting down costs. However, with its All Day Breakfast and focus on healthier food items along with a renewed focus on McCafe, it now appears that McDonald’s is better positioned to compete with Burger King ( BK ) and Tim Hortons - the coffee chain run by RBI. In the past two years, McDonald’s has been aggressively refranchising its restaurants and as both burger giants move towards a nearly 100% franchised model we expect a similar rate of growth in the franchised restaurants of both players. However, since McDonald’s has a larger base, its restaurant growth in absolute terms would be higher in the next few years. KFC is the second largest fast-food chain after McDonald’s and one of the top McDonalds Competitors. Its specialty is in fried chicken and burgers. Founded in 1930, the brand has grown and expanded into other territories with close to 20,000 branches or locations in more than 120 countries

In terms of menu choices, fast-food chains are a lot like car brands — there’s something for everyone.

Five-piece chicken nuggets for the on-the-go soccer mom. A quarter pounder with cheese for the erudite lovers of the classics. A salad for … someone.

And for the person who enjoys the finer things in life, there are the flagships: the signature burgers. Without these cheeseburgers, fast food would lose all meaning.

1 Burger King

Burger King Animation gif

Burger King Animation gif

Burger King (BK) is an American global chain of hamburger fast food restaurants. Headquartered in the unincorporated area of Miami-Dade County, Florida, the company was founded in 1953 as Insta-Burger King, a Jacksonville, Florida–based restaurant chain. After Insta-Burger King ran into financial difficulties in 1954, its two Miami-based franchisees David Edgerton and James McLamore purchased the company and renamed it “Burger King”. Over the next half-century, the company would change hands four times, with its third set of owners, a partnership of TPG Capital, Bain Capital, and Goldman Sachs Capital Partners, taking it public in 2002. In late 2010, 3G Capital of Brazil acquired a majority stake in the company, in a deal valued at US$3.26 billion. The new owners promptly initiated a restructuring of the company to reverse its fortunes. 3G, along with partner Berkshire Hathaway, eventually merged the company with the Canadian-based doughnut chain Tim Hortons, under the auspices of a new Canadian-based parent company named Restaurant Brands International.

The 1970s were the “Golden Age” of the company’s advertising, but beginning in the early-1980s, Burger King advertising began losing focus. A series of less successful advertising campaigns created by a procession of advertising agencies continued for the next two decades. In 2003, Burger King hired the Miami-based advertising agency Crispin Porter + Bogusky (CP+B), which completely reorganized its advertising with a series of new campaigns centered on a redesigned Burger King character nicknamed “The King”, accompanied by a new online presence. While highly successful, some of CP+B’s commercials were derided for perceived sexism or cultural insensitivity. Burger King’s new owner, 3G Capital, later terminated the relationship with CP+B in 2011 and moved its advertising to McGarryBowen, to begin a new product-oriented campaign with expanded demographic targeting.

Lets start to see the timeline when it starte till now. How it has expanded throughout the world. For this we need to load necessary libraries.

Lets load the necessary libraries

Load websites: Burger King From Wikipedia

I am going to extract all the location of Burger King franchise throughout the world.So best place to do would be to scrape the data from the wikipedia.

First challange would be to scrape multiple tables as their is not a single table of all the location at one place. We could scrape all individual table and bind them together so let’s write function which will be able to pull all the tables and bind them into one.

But first lets see how many tables are there in Wikipedia and we have to find table of interest.

Above line of code just return the table list but still we cannot see what is inside each table until and unless we visit the site and manually compare them. Other option will be to convert all this into table.

2 Extraction

Extract all the tables that are in the webpage

We have 15 outputs from above line of code. Now we can see all the tables that are built in the webpage. Our table of interest are from table 2 i.e 3rd output till table 8 (9th output). We can look into each table like this.

## [[1]]
##   Country/territory Yearentered                   Masterfranchisee
## 1             Egypt        2007                       Olayan Group
## 2             Ghana        2018             SIA QSR Ghana Ltd.[21]
## 3       Ivory Coast        2015              Servair Côte d'Ivoire
## 4             Kenya        2016                  Servair Kenya[22]
## 5           Morocco        2011        General First Food Services
## 6      South Africa        2013 Burger King South Africa (Pty) Ltd
##                                                                                                                                             Notes
## 1 Olayan's food service subsidiary, Hana International, is the master franchisee for the Middle East and north Africa. برغر كينغ (Arabic)[19][20]
## 2                                                                                                            First location is in the Accra Mall.
## 3                                                                                                                   First location is in Marcory.
## 4                                                                                                   First location in the Hub Karen, Nairobi.[23]
## 5                                                                                                         First location is in Casablanca; halal.
## 6                                                       First location opened in Cape Town on 9 May 2013, with plans for more nationwide.[24][25]
## [[1]]
##    Country/territory Yearentered                 Masterfranchisee
## 1          Argentina        1989 Fast Food Sudamericana S.A.[124]
## 2            Bolivia        1999         Samuel Doria Medina[125]
## 3             Brazil        2006                         Multiple
## 4           Colombia        2008                  Kinco S.A.[127]
## 5              Chile        1994 Fast Food Sudamericana S.A.[128]
## 6            Ecuador   1982[129]  Resrap/Alicosta Bk Holding[130]
## 7      French Guiana                                             
## 8             Guyana        2017                                 
## 9           Paraguay        1995               Grupo Vierci.[131]
## 10              Peru   1993[132]                     Sigdelo S.A.
## 11          Suriname        2008                         Multiple
## 12           Uruguay        2008                 Adiser S.A.[134]
## 13         Venezuela   1980[135]                                 
##                                                                      Notes
## 1                                                                         
## 2                                                                         
## 3                       Operates with a territorial franchises system[126]
## 4                                                    Operated during 1980s
## 5                                                                         
## 6                                                                         
## 7                                                                         
## 8                                                                         
## 9                                                                         
## 10                                                                        
## 11 The first restaurant is located in the capital city of Paramaribo.[133]
## 12                                                                        
## 13

One option would be to just bind all the tables into one by passing bind_rows function but the issue is some of the table column name is integer and some of them is character. and will take longer time to change each if we have multiple tables. Luckily we have only 9 table of interest here.

## List of 1
##  $ :'data.frame':    6 obs. of  4 variables:
##   ..$ Country/territory: chr [1:6] "Egypt" "Ghana" "Ivory Coast" "Kenya" ...
##   ..$ Yearentered      : int [1:6] 2007 2018 2015 2016 2011 2013
##   ..$ Masterfranchisee : chr [1:6] "Olayan Group" "SIA QSR Ghana Ltd.[21]" "Servair Côte d'Ivoire" "Servair Kenya[22]" ...
##   ..$ Notes            : chr [1:6] "Olayan's food service subsidiary, Hana International, is the master franchisee for the Middle East and north Af"| __truncated__ "First location is in the Accra Mall." "First location is in Marcory." "First location in the Hub Karen, Nairobi.[23]" ...
## List of 1
##  $ :'data.frame':    33 obs. of  4 variables:
##   ..$ Country         : chr [1:33] "Afghanistan" "Bahrain" "Bangladesh" "Brunei" ...
##   ..$ Yearentered     : chr [1:33] "" "" "2016" "2014" ...
##   ..$ Masterfranchisee: chr [1:33] "Army and Air ForceExchange Service (AAFES)" "Jawad Business Group (UAE)" "Tiffin Box (Bangla Trac)" "Sinofood Express" ...
##   ..$ Notes           : chr [1:33] "" "Halal[36]" "Nine branches opened at Banani, Bashundhara, Uttara, Dhanmondi, Jamuna Future Park, Mirpur, Gulshan, New Market"| __truncated__ "The first store opened in February 2014 in Bandar Seri Begawan." ...
## List of 1
##  $ :'data.frame':    14 obs. of  4 variables:
##   ..$ Country/territory: chr [1:14] "Antigua and Barbuda" "Aruba" "Bahamas" "Barbados" ...
##   ..$ Yearentered      : int [1:14] 2012 1981 NA 2013 NA NA 1994 1985 NA 1963 ...
##   ..$ Masterfranchisee : chr [1:14] "" "All American Burgers Inc." "" "" ...
##   ..$ Notes            : chr [1:14] "Opened on 27 March, second branch opened in 1st half of 2013" "First hamburger QSR (quick service restaurant) to enter market" "" "" ...
## List of 1
##  $ :'data.frame':    41 obs. of  4 variables:
##   ..$ Country/territory: chr [1:41] "Albania" "Andorra" "Austria" "Armenia" ...
##   ..$ Yearentered      : chr [1:41] "2019" "" "" "2017" ...
##   ..$ Masterfranchisee : chr [1:41] "Buçaj Retail" "" "Theophil Holding GmbH" "" ...
##   ..$ Notes            : chr [1:41] "First outlet was opened at the QTU Shopping Mall on June 1, 2019. The outlet is the first out of the 20 that ha"| __truncated__ "4 restaurants in 2018" "46 restaurants as of May 2017" "The first restaurant was opened in Yerevan on 11 January 2017. Burger King currently has three outlets in Armenia." ...

As you can see the year entered in table 3 is character and in table 4 it is integer. Similarly we have Column name for table 2 is Country/territory but in table 3 it is just Country.

## Observations: 74
## Variables: 5
## $ Country             <chr> "Afghanistan", "Bahrain", "Bangladesh", "Bru…
## $ Yearentered         <chr> "", "", "2016", "2014", "2013", "2005", "197…
## $ Masterfranchisee    <chr> "Army and Air ForceExchange Service (AAFES)"…
## $ Notes               <chr> "", "Halal[36]", "Nine branches opened at Ba…
## $ `Country/territory` <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …

Alternative way to do same thing much less hassle way.

Lets write a function to extract all the tables of interest from above list.

3 Function :

Extract all the tables.

Xpath : //*[@id="mw-content-text"]/div/table[2]

  1. I get this by going to inspect page.
  2. Then scroll around the Elements tab all the line until and unless it starts select/highlights the first table.
  3. You will see …(3 dots) on the right hand side of inspect page.
  4. Click on that and then click on copy and the copy Xpath.
  5. Scroll to another table and do the same thing and now we see the pattern the only difference between all the table is table number.

Just for demonstration purpose I have copy all the Xpath for each table of interest. Now we can built the function based on this. To diagnose more how it is built click on table breakdown(triangle) then see on right hand side of page on Styles tab.We will see it is wrapped around {}. So we just have to substitute number with {}.

//[@id="mw-content-text"]/div/table[2]
//
[@id="mw-content-text"]/div/table[3]
//[@id="mw-content-text"]/div/table[4]
//
[@id="mw-content-text"]/div/table[5]
//[@id="mw-content-text"]/div/table[6]
//
[@id="mw-content-text"]/div/table[7]
//[@id="mw-content-text"]/div/table[8]
//
[@id="mw-content-text"]/div/table[9]

Extract all the 6 tables and bind them using map function.

As in table 3 we have colnames Country and rest of the table has column name country/territory. If we combine them all them the country from table 3 will have missing data NA.
So we couldn’t do bk_data_2 <- map_dfr(2:8, extract_table_df) like this. So I would break them and change column name before combining so we have less missing Data “NA”.

## Observations: 6
## Variables: 4
## $ `Country/territory` <chr> "Egypt", "Ghana", "Ivory Coast", "Kenya", "M…
## $ Yearentered         <chr> "2007", "2018", "2015", "2016", "2011", "201…
## $ Masterfranchisee    <chr> "Olayan Group", "SIA QSR Ghana Ltd.[21]", "S…
## $ Notes               <chr> "Olayan's food service subsidiary, Hana Inte…
## Observations: 33
## Variables: 4
## $ Country          <chr> "Afghanistan", "Bahrain", "Bangladesh", "Brunei…
## $ Yearentered      <chr> "", "", "2016", "2014", "2013", "2005", "1979",…
## $ Masterfranchisee <chr> "Army and Air ForceExchange Service (AAFES)", "…
## $ Notes            <chr> "", "Halal[36]", "Nine branches opened at Banan…
## Observations: 80
## Variables: 4
## $ `Country/territory` <chr> "Antigua and Barbuda", "Aruba", "Bahamas", "…
## $ Yearentered         <chr> "2012", "1981", NA, "2013", NA, NA, "1994", …
## $ Masterfranchisee    <chr> "", "All American Burgers Inc.", "", "", "",…
## $ Notes               <chr> "Opened on 27 March, second branch opened in…

4 Data Cleaning

## Observations: 119
## Variables: 5
## $ `Country/territory` <chr> "Egypt", "Ghana", "Ivory Coast", "Kenya", "M…
## $ Yearentered         <chr> "2007", "2018", "2015", "2016", "2011", "201…
## $ Masterfranchisee    <chr> "Olayan Group", "SIA QSR Ghana Ltd.[21]", "S…
## $ Notes               <chr> "Olayan's food service subsidiary, Hana Inte…
## $ Country             <chr> NA, NA, NA, NA, NA, NA, "Afghanistan", "Bahr…

We have 119 Observations. and 4 variables

## Observations: 119
## Variables: 6
## $ `Country/territory` <chr> "Egypt", "Ghana", "Ivory Coast", "Kenya", "M…
## $ Yearentered         <chr> "2007", "2018", "2015", "2016", "2011", "201…
## $ Masterfranchisee    <chr> "Olayan Group", "SIA QSR Ghana Ltd.[21]", "S…
## $ Notes               <chr> "Olayan's food service subsidiary, Hana Inte…
## $ Country             <chr> NA, NA, NA, NA, NA, NA, "Afghanistan", "Bahr…
## $ country             <chr> "Egypt", "Ghana", "Ivory Coast", "Kenya", "M…

As we can see that only missing variables from web extraction is years entered which is not given in wikipedia as well. So after cross referencing what I found to be true.

## [1] "1991" "2014" "1990" "2006" "2008"

As we can see the yearentered column needs some clean up as the refernce attached to yearentered has also came along with it. We just need is beginning four digit year ignoring the reference.

5 Data Tidy

Tidy the text data

As we can see it has only taken first 4 digits from the yearenetered column.

## [1] 101

We have 101 unique countries in our burger king datasets.

Now we have clean data from the web but we are missing the world map spatial data which we can get from rnaturalearth package.

## Simple feature collection with 1 feature and 1 field
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -180 ymin: -89.99893 xmax: 180 ymax: 83.59961
## epsg (SRID):    4326
## proj4string:    +proj=longlat +datum=WGS84 +no_defs
## # A tibble: 1 x 2
##       n                                                            geometry
##   <int>                                                  <MULTIPOLYGON [°]>
## 1   241 (((-150.2325 -76.77646, -150.6552 -76.78896, -150.8305 -76.76152, …

Before we plot we need to find that all our country of interest data are in multiploygon package and we don’t have any missing data or mismatching country name. Let’s run the sanity check for all the country name before we plot.

name_en: Name in English

##   Country/territory Yearentered        Masterfranchisee     Country
## 1              <NA>        2005                               China
## 2              <NA>        2013     Fast Food Timor Lda Timor-Leste
## 3         Macedonia        2011                TAB Gıda        <NA>
## 4     United States    19541957 Burger King Corporation        <NA>
##         country year
## 1         China 2005
## 2   Timor-Leste 2013
## 3     Macedonia 2011
## 4 United States 1954
## [1] "China"               "Timor-Leste"         "Bahamas"            
## [4] "U.S. Virgin Islands" "Gibraltar"           "Macedonia"          
## [7] "United States"       "French Guiana"

We can see there are 4 matches. 4 others countries have no information about the opening year. So lets just correct 4 that has been mismatched and leave the other 4.

We can see all the english country name by expanding spatial countries that didn’t match. Let’s choose by the first letter. Lets try to look through the first letter of the word.

## [1] "Croatia"                  "Mongolia"                
## [3] "Turkmenistan"             "Thailand"                
## [5] "Cuba"                     "Malawi"                  
## [7] "Tanzania"                 "Central African Republic"

Let’s try the grep function which is much better in pattern recognition that getting first letter of the word.

## [1] "People's Republic of China"
## [1] "Republic of Macedonia"
## [1] "East Timor"
## [1] "United States Virgin Islands" "United States of America"    
## [3] "United Kingdom"               "United Arab Emirates"

Advantages of using grep function is even the name of Country like Timor-Leste has been changed we can still find by providing Timor name same goes for China.

After we have found out 4 countries we need to include them. We can use tribble function to create a datasets with two column one with the country name which is perfect match and one with the datasets that is bk_tidy_data

## # A tibble: 4 x 2
##   country       spatial_countries         
##   <chr>         <chr>                     
## 1 United States United States of America  
## 2 Macedonia     Republic of Macedonia     
## 3 Timor-Leste   East Timor                
## 4 China         People's Republic of China

We can now completely join the match country data that we just created to the bk_tidy_data

Sanity Check

Lets plot the base map

Burger King Animation gif

Burger King Animation gif Now to save the gif to our working directory.

Wow!!!. It seems quite beautiful journey and can be done with less lines of code. Similarly Lets move on to Competitor McDonald’s Timeline chart

6 2. McDonald’s

Macdonalds Animation gif

Macdonalds Animation gif

McDonald’s is an American fast food company, founded in 1940 as a restaurant operated by Richard and Maurice McDonald, in San Bernardino, California, United States. They rechristened their business as a hamburger stand, and later turned the company into a franchise, with the Golden Arches logo being introduced in 1953 at a location in Phoenix, Arizona. In 1955, Ray Kroc, a businessman, joined the company as a franchise agent and proceeded to purchase the chain from the McDonald brothers. McDonald’s had its original headquarters in Oak Brook, Illinois, but moved its global headquarters to Chicago in early 2018.

McDonald’s is the world’s largest restaurant chain by revenue,[8] serving over 69 million customers daily in over 100 countries[9] across 37,855 outlets as of 2018.Although McDonald’s is best known for its hamburgers, cheeseburgers and french fries, they also feature chicken products, breakfast items, soft drinks, milkshakes, wraps, and desserts. In response to changing consumer tastes and a negative backlash because of the unhealthiness of their food,[12] the company has added to its menu salads, fish, smoothies, and fruit. The McDonald’s Corporation revenues come from the rent, royalties, and fees paid by the franchisees, as well as sales in company-operated restaurants. According to two reports published in 2018, McDonald’s is the world’s second-largest private employer with 1.7 million employees (behind Walmart with 2.3 million employees)

Let’s load the necessary libraries.

Lets scrape all the location timeline from the wikipedia as well.

Similarly as we have done for the Burger King.let’s Extract all the tables that are in the webpage

7 Extraction

Out of 9 outputs, our table of interest is Table 2 (3rd Output). In this case we don’t have to merge/combine as we can get all the observation in one table.

## List of 1
##  $ :'data.frame':    121 obs. of  8 variables:
##   ..$ #                                    : int [1:121] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ Name of country                      : chr [1:121] "United States" "Canada (details)" "Puerto Rico(part of  United States)" "U.S. Virgin Islands(part of  United States)" ...
##   ..$ Date of first store                  : chr [1:121] "May 15, 1940Franchise: April 13, 1955" "June 3, 1967" "December 6, 1967" "September 5, 1970" ...
##   ..$ First outlet location                : chr [1:121] "San Bernardino, CaliforniaDes Plaines, Illinois (Franchise)" "Richmond, British Columbia" "San Juan" "St. Croix" ...
##   ..$ Number of currently operating outlets: chr [1:121] "14,146[9]" "1,450[10]" "108" "6" ...
##   ..$ Source and date of source            : chr [1:121] "(source: Investopedia November 15, 2018)" "(source: Investopedia November 15, 2018)" "(source: McDonald's 2013)" "(source: McDonald's 2013)" ...
##   ..$ People per outlet                    : chr [1:121] "23,130" "25,559" "29,583" "17,878" ...
##   ..$ Notes                                : chr [1:121] "See McDonald's USA" "This is the first McDonalds outside of United States See\nMcDonalds Canada McDonald's Canada" "First McDonald's in Latin America and in the Caribbean. See McDonald's Puerto Rico" "" ...

8 Function

Lets see the table

## List of 1
##  $ :'data.frame':    121 obs. of  8 variables:
##   ..$ #                                    : int [1:121] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ Name of country                      : chr [1:121] "United States" "Canada (details)" "Puerto Rico(part of  United States)" "U.S. Virgin Islands(part of  United States)" ...
##   ..$ Date of first store                  : chr [1:121] "May 15, 1940Franchise: April 13, 1955" "June 3, 1967" "December 6, 1967" "September 5, 1970" ...
##   ..$ First outlet location                : chr [1:121] "San Bernardino, CaliforniaDes Plaines, Illinois (Franchise)" "Richmond, British Columbia" "San Juan" "St. Croix" ...
##   ..$ Number of currently operating outlets: chr [1:121] "14,146[9]" "1,450[10]" "108" "6" ...
##   ..$ Source and date of source            : chr [1:121] "(source: Investopedia November 15, 2018)" "(source: Investopedia November 15, 2018)" "(source: McDonald's 2013)" "(source: McDonald's 2013)" ...
##   ..$ People per outlet                    : chr [1:121] "23,130" "25,559" "29,583" "17,878" ...
##   ..$ Notes                                : chr [1:121] "See McDonald's USA" "This is the first McDonalds outside of United States See\nMcDonalds Canada McDonald's Canada" "First McDonald's in Latin America and in the Caribbean. See McDonald's Puerto Rico" "" ...

We can see 121 observation and 8 variables which mateches the wikipedia McDonald’s result. Lets save as mac_data

Sanity Check

After importing the data from the webpage it’s always best idea to see that we extracted all the information from the required page without missing a single piece of information.

9 Data Cleaning

It seems like Wikipedia has done wonderful job in storing all the data without missing a single piece of information. None of the table has any missing piece of information.

## Observations: 121
## Variables: 8
## $ x                                     <int> 1, 2, 3, 4, 5, 6, 7, 8, 9,…
## $ name_of_country                       <chr> "United States", "Canada (…
## $ date_of_first_store                   <chr> "May 15, 1940Franchise: Ap…
## $ first_outlet_location                 <chr> "San Bernardino, Californi…
## $ number_of_currently_operating_outlets <chr> "14,146[9]", "1,450[10]", …
## $ source_and_date_of_source             <chr> "(source: Investopedia Nov…
## $ people_per_outlet                     <chr> "23,130", "25,559", "29,58…
## $ notes                                 <chr> "See McDonald's USA", "Thi…
## Observations: 121
## Variables: 7
## $ x                                     <int> 1, 2, 3, 4, 5, 6, 7, 8, 9,…
## $ date_of_first_store                   <chr> "May 15, 1940Franchise: Ap…
## $ first_outlet_location                 <chr> "San Bernardino, Californi…
## $ number_of_currently_operating_outlets <chr> "14,146[9]", "1,450[10]", …
## $ source_and_date_of_source             <chr> "(source: Investopedia Nov…
## $ people_per_outlet                     <chr> "23,130", "25,559", "29,58…
## $ country                               <chr> "United States", "Canada (…

Challange associated with this extraction is now we just need is country name and have to ignore all the links that came attached along with it. We can do this by using gsub function. In first line of code I am just interested in country name and ignoring all the strings that is enclosed inside the bracket.

Let’s see how many rows we have where country is followed by some reference ()

## [1] "length of Column"
## [1] 16
## [1] "Row Number"
##  [1]   2   3   4   7  12  18  20  44  45  47  48  56  62  63  84 113
## [1] "Country name with the bracket"
##  [1] "Canada (details)"                                   
##  [2] "Puerto Rico(part of  United States)"                
##  [3] "U.S. Virgin Islands(part of  United States)"        
##  [4] "Guam(part of  United States)"                       
##  [5] "France (details)"                                   
##  [6] "Hong Kong( British Hong Kong at the time)"          
##  [7] "New Zealand (details)"                              
##  [8] "Macau(  Portuguese Macau at the time)"              
##  [9] "Serbia(part of  Yugoslavia at the time)"            
## [10] "Hungary( HPR at the time)"                          
## [11] "Russia(part of  Soviet Union at the time)"          
## [12] "Czech Republic(part of  Czechoslovakia at the time)"
## [13] "Northern Marianas(part of  United States)"          
## [14] "Israel (details)"                                   
## [15] "Samoa(named Western Samoa at the time)"             
## [16] "American Samoa(part of  United States)"

So we see there are 16 countries out of 121 that have reference followed along with them while extracting from Wikipedia. Now as this information is irrelevant from the animation chart goal. We can ignore them and only extract country name.

Sanity Check Let’s see if we have any country that have bracket in it.

## [1] 0
## character(0)

So now our country name extracted is clean.Let’s move on date of first store opening column and see if the data is clean.

We can ignore the country variables but then we will run into another problem that is all the dates will bind together.

Also,lets drop the coming soon countries which has not been open yet.

## Observations: 118
## Variables: 8
## $ x                                     <int> 1, 2, 3, 4, 5, 6, 7, 8, 9,…
## $ date_of_first_store                   <chr> "May 15, 1940Franchise: Ap…
## $ first_outlet_location                 <chr> "San Bernardino, Californi…
## $ number_of_currently_operating_outlets <chr> "14,146[9]", "1,450[10]", …
## $ source_and_date_of_source             <chr> "(source: Investopedia Nov…
## $ people_per_outlet                     <chr> "23,130", "25,559", "29,58…
## $ country                               <chr> "United States", "Canada",…
## $ year                                  <chr> "1940", "1967", "1967", "1…

We have 118 Observation as we have dropped down 3 Rows where McDonalds was coming soon.Lets change year column to date from Character.

10 Data Tidy

## Simple feature collection with 1 feature and 1 field
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -180 ymin: -89.99893 xmax: 180 ymax: 83.59961
## epsg (SRID):    4326
## proj4string:    +proj=longlat +datum=WGS84 +no_defs
## # A tibble: 1 x 2
##       n                                                            geometry
##   <int>                                                  <MULTIPOLYGON [°]>
## 1   241 (((-150.2325 -76.77646, -150.6552 -76.78896, -150.8305 -76.76152, …

We have to look for any country mismatch like what we did in Burger King Analysis.

## # A tibble: 11 x 2
##    country             spatial_countries                  
##    <chr>               <chr>                              
##  1 United States       United States of America           
##  2 U.S. Virgin Islands United States Virgin Islands       
##  3 Curacao             Curaçao                            
##  4 Bahamas             The Bahamas                        
##  5 PR of China         People's Republic of China         
##  6 Martinique          French Southern and Antarctic Lands
##  7 Guadeloupe          French Southern and Antarctic Lands
##  8 Northern Marianas   Northern Mariana Islands           
##  9 Reunion             French Southern and Antarctic Lands
## 10 Gibraltar           British Indian Ocean Territory     
## 11 French Guiana       French Southern and Antarctic Lands

Sanity check

##   [1] x                                    
##   [2] date_of_first_store                  
##   [3] first_outlet_location                
##   [4] number_of_currently_operating_outlets
##   [5] source_and_date_of_source            
##   [6] people_per_outlet                    
##   [7] country                              
##   [8] year                                 
##   [9] spatial_countries                    
##  [10] featurecla                           
##  [11] scalerank                            
##  [12] labelrank                            
##  [13] sovereignt                           
##  [14] sov_a3                               
##  [15] adm0_dif                             
##  [16] level                                
##  [17] type                                 
##  [18] admin                                
##  [19] adm0_a3                              
##  [20] geou_dif                             
##  [21] geounit                              
##  [22] gu_a3                                
##  [23] su_dif                               
##  [24] subunit                              
##  [25] su_a3                                
##  [26] brk_diff                             
##  [27] name                                 
##  [28] name_long                            
##  [29] brk_a3                               
##  [30] brk_name                             
##  [31] brk_group                            
##  [32] abbrev                               
##  [33] postal                               
##  [34] formal_en                            
##  [35] formal_fr                            
##  [36] name_ciawf                           
##  [37] note_adm0                            
##  [38] note_brk                             
##  [39] name_sort                            
##  [40] name_alt                             
##  [41] mapcolor7                            
##  [42] mapcolor8                            
##  [43] mapcolor9                            
##  [44] mapcolor13                           
##  [45] pop_est                              
##  [46] pop_rank                             
##  [47] gdp_md_est                           
##  [48] pop_year                             
##  [49] lastcensus                           
##  [50] gdp_year                             
##  [51] economy                              
##  [52] income_grp                           
##  [53] wikipedia                            
##  [54] fips_10_                             
##  [55] iso_a2                               
##  [56] iso_a3                               
##  [57] iso_a3_eh                            
##  [58] iso_n3                               
##  [59] un_a3                                
##  [60] wb_a2                                
##  [61] wb_a3                                
##  [62] woe_id                               
##  [63] woe_id_eh                            
##  [64] woe_note                             
##  [65] adm0_a3_is                           
##  [66] adm0_a3_us                           
##  [67] adm0_a3_un                           
##  [68] adm0_a3_wb                           
##  [69] continent                            
##  [70] region_un                            
##  [71] subregion                            
##  [72] region_wb                            
##  [73] name_len                             
##  [74] long_len                             
##  [75] abbrev_len                           
##  [76] tiny                                 
##  [77] homepart                             
##  [78] min_zoom                             
##  [79] min_label                            
##  [80] max_label                            
##  [81] ne_id                                
##  [82] wikidataid                           
##  [83] name_ar                              
##  [84] name_bn                              
##  [85] name_de                              
##  [86] name_es                              
##  [87] name_fr                              
##  [88] name_el                              
##  [89] name_hi                              
##  [90] name_hu                              
##  [91] name_id                              
##  [92] name_it                              
##  [93] name_ja                              
##  [94] name_ko                              
##  [95] name_nl                              
##  [96] name_pl                              
##  [97] name_pt                              
##  [98] name_ru                              
##  [99] name_sv                              
## [100] name_tr                              
## [101] name_vi                              
## [102] name_zh                              
## [103] geometry                             
## <0 rows> (or 0-length row.names)

McDonalds Animation gif

Macdonalds Animation gif

Macdonalds Animation gif

Awesome, Bravo!!!. It feel little different than Burger King may be little easy cake walk but was definetly different level of data cleaning step and was not repetation. Now lets move onto KFC(Kentucky Fried Chicken) and see if we could generate Similar kind of Chart.

11 3. Kentucky Fried Chicken (KFC)

KFC Animation gif Now to save the gif to our working directory.

KFC, also known as Kentucky Fried Chicken, is an American fast food restaurant chain headquartered in Louisville, Kentucky, that specializes in fried chicken. It is the world’s second-largest restaurant chain (as measured by sales) after McDonald’s, with 22,621 locations globally in 136 countries as of December 2018.The chain is a subsidiary of Yum! Brands, a restaurant company that also owns the Pizza Hut, Taco Bell, and WingStreet chains.

KFC Hot Wings and fries KFC was founded by Colonel Harland Sanders, an entrepreneur who began selling fried chicken from his roadside restaurant in Corbin, Kentucky, during the Great Depression. Sanders identified the potential of the restaurant franchising concept, and the first “Kentucky Fried Chicken” franchise opened in Utah in 1952. KFC popularized chicken in the fast food industry, diversifying the market by challenging the established dominance of the hamburger. By branding himself as “Colonel Sanders”, Harland became a prominent figure of American cultural history, and his image remains widely used in KFC advertising to this day. However, the company’s rapid expansion overwhelmed the aging Sanders, and he sold it to a group of investors led by John Y. Brown Jr. and Jack C. Massey in 1964.

KFC was one of the first American fast food chains to expand internationally, opening outlets in Canada, the United Kingdom, Mexico, and Jamaica by the mid-1960s. Throughout the 1970s and 1980s, it experienced mixed fortunes domestically, as it went through a series of changes in corporate ownership with little or no experience in the restaurant business

Lets load the necessary libraries for this part.

Load websites: KFC

What better place would it be beside Wikipedia to extract all the location of KFC.

12 Extraction

We have 17 outputs. Our table of interest is not a single table but would be combination of multiple tables as we did in Burger King Webscrapping project. After identifying first and last table lets have a look and do sanity check with Wikipedia. Remember our goal is to extract all the table information without missing a single data.

## [[1]]
##         Country Yearentered                        Owner/major operator
## 1        Angola     2012[9]                            Grupo Ibersol[9]
## 2      Botswana    1992[10]               Venture Partners Botswana[11]
## 3         Egypt        1973                         Americana Group[13]
## 4      Eswatini        1993                                            
## 5         Gabon        2019                             Resto Group[14]
## 6         Ghana    2011[15]                          Mohinani Group[15]
## 7   Ivory Coast        2018                                            
## 8         Kenya    2011[16]                  Kuku Foods East Africa[17]
## 9       Lesotho    2012[19]                            KFC South Africa
## 10       Malawi    2012[20]                       Afribrand Limited[20]
## 11    Mauritius    1983[21]                     Food & Allied Group[21]
## 12      Morocco        2001                         Americana Group[13]
## 13   Mozambique        2007                               Grupo Ibersol
## 14      Namibia    1992[19]                            KFC South Africa
## 15      Nigeria    2009[22]   Devyani International Nigeria Limited[23]
## 16 South Africa    1971[20] Yum Restaurants International (Pty) Ltd[24]
## 17     Tanzania     2013[7]                                            
## 18      Tunisia    2018[28]                                   HBG group
## 19       Uganda        2013                  Kuku Foods East Africa[29]
## 20       Zambia    2011[30]                                            
##                                                                                                                                                                                                                                                                     Notes
## 1                                                                                                                                                                                                                55 outlets. First outlet opened in Maianga in Luanda.[9]
## 2                                                                                                                                                                                                              First outlet opened in Gaborone. Currently 11 outlets.[12]
## 3                                                                                                                                                                                                                                                        156 outlets.[12]
## 4                                                                                                                                                                                                                      First outlet opened in Mbabane. Seven outlets.[12]
## 5                                                                                                                                                                                                                                      First outlet opened in Libreville.
## 6                                                                                                                                                                                                               First outlet opened in Greater Accra.[15] 15 outlets.[12]
## 7                                                                                                                                                                     KFC opened their first outlet in Ivory Coast in Abidjan, Marcory on 28 March 2018.[citation needed]
## 8                                                                                                                                                                                   First opened, briefly, in the 1970s.[18] Reopened in Nairobi in 2011.[16] 17 outlets.
## 9                                                                                                                                                                                                                                                          5 outlets.[12]
## 10                                                                                                                                                                                                                               First outlet in Blantyre. 2 outlets.[20]
## 11                                                                                                                                                                                                                          First outlet in Curepipe.[21] 21 outlets.[12]
## 12                                                                                                                                                                                                                                                        12 outlets.[12]
## 13                                                                                                                                                                                                                         First outlet opened in Maputo. 10 outlets.[12]
## 14                                                                                                                                                                                                                                                        18 outlets.[12]
## 15                                                                                                                                                                                                      First branch opened in Lagos in 2009.[20] 27 outlets by 2014.[22]
## 16 884 outlets. Divested its holdings from 1987 until 1994 to a holding company after U.S. Congress passed a law forbidding U.S. companies from owning South African assets.[25] KFC sold its assets to Devco, an administrative entity, which managed the trademark.[26]
## 17                                                                                                                                                                                                                              First outlet opened in Dar es Salaam.[27]
## 18                                                                                                                                                                                                                                3 outlets in Lac 1, Lac 2 and La Marsa.
## 19                                                                                                                                                                                                                                        First outlet opened in Kampala.
## 20                                                                                                                                                                    By the end of 2011, four outlets had been opened in shopping centres in the capital city of Lusaka.
## [[1]]
##                    Country Yearentered   Owner/major operator
## 1           American Samoa        1984                       
## 2                Australia        1968  KFC Australia Pty Ltd
## 3                     Guam   1975[201]                       
## 4              New Zealand   1971[202] Restaurant Brands[202]
## 5 Northern Mariana Islands        1986                       
##                                                                                                                              Notes
## 1                                                                    Had two outlets. Now there is one with a Pizza Hut franchise.
## 2 There are 650 outlets in Australia. The first Australian KFC was built and opened at Guildford in the western suburbs of Sydney.
## 3                                                                                 First store in Tamuning.[201] Seven outlets.[12]
## 4                                                        First store opened in Royal Oak, Auckland.[202] 100 outlets in 2013.[203]
## 5                                                                                                            One outlet in Saipan.

Our next step is to verify that we have all tables matched along. So lets have a quick pick on all the tables that we are planning to merge. I have excluded Future market as it doesnt make sense to plot until and unless it has open.

Although our interest column the country and year entered and year existed is mixed up between the tables. We need to rearrange and clean up little more before we could merge and then plot.

## List of 1
##  $ :'data.frame':    20 obs. of  4 variables:
##   ..$ Country             : chr [1:20] "Angola" "Botswana" "Egypt" "Eswatini" ...
##   ..$ Yearentered         : chr [1:20] "2012[9]" "1992[10]" "1973" "1993" ...
##   ..$ Owner/major operator: chr [1:20] "Grupo Ibersol[9]" "Venture Partners Botswana[11]" "Americana Group[13]" "" ...
##   ..$ Notes               : chr [1:20] "55 outlets. First outlet opened in Maianga in Luanda.[9]" "First outlet opened in Gaborone. Currently 11 outlets.[12]" "156 outlets.[12]" "First outlet opened in Mbabane. Seven outlets.[12]" ...
## List of 1
##  $ :'data.frame':    26 obs. of  4 variables:
##   ..$ Country             : chr [1:26] "Azerbaijan" "Bangladesh" "Brunei" "China" ...
##   ..$ Yearentered         : chr [1:26] "2011[31]" "2006[34]" "1992[citation needed]" "1987[35]" ...
##   ..$ Owner/major operator: chr [1:26] "AFK Ltd[31]" "Transcom Group[34]" "" "KFC China[36]" ...
##   ..$ Notes               : chr [1:26] "In October 2012, the world's largest KFC  opened in Baku. The 1,600-square-meter outlet, with a seating capacit"| __truncated__ "First outlet opened at Gulshan in 2006. As of 2018, there are 21 outlets; 18 in Dhaka,  1 in Chittagong, 1 in S"| __truncated__ "15 outlets." "KFC's largest market. The first Kentucky Fried Chicken outlet opened on Qianmen Street in downtown Beijing in 1"| __truncated__ ...
## List of 1
##  $ :'data.frame':    37 obs. of  4 variables:
##   ..$ Country             : chr [1:37] "Antigua and Barbuda" "Argentina" "Aruba" "Bahamas" ...
##   ..$ Yearentered         : chr [1:37] "" "2010" "" "1967[88]" ...
##   ..$ Owner/major operator: chr [1:37] "KFC Antigua[84]" "Desarrollos Gastronomicos S.A." "Hucor Holding" "Myers Group[89]" ...
##   ..$ Notes               : chr [1:37] "3 branches in Antigua in 2012.[85]" "First opened in 1980 but closed in 1990. In 2010, KFC reopened in Buenos Aires. 10 outlets.[86][87]" "Four outlets.[12]" "9 branches in 2012.[90]" ...
## List of 1
##  $ :'data.frame':    38 obs. of  4 variables:
##   ..$ Country             : chr [1:38] "Albania" "Armenia" "Austria" "Belarus" ...
##   ..$ Yearentered         : chr [1:38] "2016" "2007[128]" "2005[129]" "2015" ...
##   ..$ Owner/major operator: chr [1:38] "" "9 outlets (8 in Yerevan, 1 in Vanadzor)" "Queensway Restaurants Ltd[65]AmRest[130]" "Bel Food Service LLC, CreativeFood-S-Vostok LLC" ...
##   ..$ Notes               : chr [1:38] "First outlet in Albania opened in Tirana on April 14, 2016 at the Tirana East Gate Mall.[127] The second one op"| __truncated__ "" "First entered the country in 1970 but withdrew.[131] Returned in 2005 with a store in Vienna.[65] 6 outlets as "| __truncated__ "16 restaurants in January 2019." ...

13 Function

Alternative way to do same thing much less hassle way.

Lets write a function to extract all the tables of interest from above list.

Extract all the tables.

Xpath: //*[@id="mw-content-text"]/div/table[2] : Same way I extracted inspecting the page.

14 Extract all the 6 tables and bind them using map function.

Our table of interest is from table 2 to 8 and we have to ignore table 9 & 10 because table 9 & 10 is the year they left the countries. So we have combine from table 2-8 and then 11-13.So lets do that and see if we could extract all the codes.

## Observations: 141
## Variables: 4
## $ Country                <chr> "Angola", "Botswana", "Egypt", "Eswatini"…
## $ Yearentered            <chr> "2012[9]", "1992[10]", "1973", "1993", "2…
## $ `Owner/major operator` <chr> "Grupo Ibersol[9]", "Venture Partners Bot…
## $ Notes                  <chr> "55 outlets. First outlet opened in Maian…
## Observations: 3
## Variables: 4
## $ Country     <chr> "Haiti", "Andorra", "Fiji"
## $ Yearentered <chr> "Late 1970s-1997[208]", "1979-2014", "1980s-2013"
## $ Owner       <lgl> NA, NA, NA
## $ Notes       <chr> NA, "KFC closed its doors in Andorra in 2014.[12]", …

We have 141 observation with 4 variables from table 2 to table 8 and then from table 11 -13 we have 3 observation and 4 variables. So lets merge together and have one table with all info. There is one problem merging this data as we have Owner column name different in two group. Although the column is none of our interest for this project. Anways I want to import right way.

15 Data Cleaning

We have 144 Observations. and 4 variables. Next step would be to clean the column names so that we could not end up having syntax error because of white space.

## Observations: 144
## Variables: 4
## $ country     <chr> "Angola", "Botswana", "Egypt", "Eswatini", "Gabon", …
## $ yearentered <chr> "2012[9]", "1992[10]", "1973", "1993", "2019", "2011…
## $ owner       <chr> "Grupo Ibersol[9]", "Venture Partners Botswana[11]",…
## $ notes       <chr> "55 outlets. First outlet opened in Maianga in Luand…

After importing data lets see if we have any missing data and cross check with wikipedia.

Good News is the yearentered and country have no missing values which is of our interest.

## 
## 1967[120] 2010[189]  2013[53]      2010 2006[173] 
##         1         1         1         4         1

As we can see the yearentered column needs some clean up as the reference attached to yearentered has also came along with it. We just need is beginning four digit year ignoring the reference.

16 Data Tidy

Tidy the text data

## [1] 131

We have 131 unique countries in our KFC datasets.

Now we have clean data from the web but we are missing the world map spatial data which we can get from rnaturalearth package.

## Simple feature collection with 1 feature and 1 field
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -180 ymin: -89.99893 xmax: 180 ymax: 83.59961
## epsg (SRID):    4326
## proj4string:    +proj=longlat +datum=WGS84 +no_defs
## # A tibble: 1 x 2
##       n                                                            geometry
##   <int>                                                  <MULTIPOLYGON [°]>
## 1   241 (((-150.2325 -76.77646, -150.6552 -76.78896, -150.8305 -76.76152, …

Before we plot we need to find that all our country of interest data are in multiploygon package and we don’t have any missing data or mismatching country name. Let’s run the sanity check for all the country name before we plot.

name_en: Name in English

##           country yearentered
## 1        Eswatini        1993
## 2           China    1987[35]
## 3         Bahamas    1967[88]
## 4         Bonaire        1992
## 5 North Macedonia   2018[163]
## 6     Turkey[192]        1989
## 7   United States        1930
##                                             owner year
## 1                                                 1993
## 2                                   KFC China[36] 1987
## 3                                 Myers Group[89] 1967
## 4 Harborside Foodcourt, NV, Ruth van Tilburg-Obre 1992
## 5                               KAN International 2018
## 6                                     Yum! Brands 1989
## 7                                                 1930

We can see there are 7 mismatches between the data we extracted from the webpage and the spatial countries from the package.

Let’s create a table of the country and matched them respectively.

##  [1] "Cayman Islands"           "Cook Islands"            
##  [3] "Curaçao"                  "Czech Republic"          
##  [5] "Cyprus"                   "Cuba"                    
##  [7] "Croatia"                  "Costa Rica"              
##  [9] "Comoros"                  "Colombia"                
## [11] "Chile"                    "Chad"                    
## [13] "Central African Republic" "Cape Verde"              
## [15] "Canada"                   "Cameroon"                
## [17] "Cambodia"
## # A tibble: 7 x 2
##   country         spatial_countries         
##   <chr>           <chr>                     
## 1 Eswatini        eSwatini                  
## 2 China           People's Republic of China
## 3 Bahamas         The Bahamas               
## 4 Bonaire         Netherlands               
## 5 North Macedonia Republic of Macedonia     
## 6 Turkey[192]     Turkey                    
## 7 United States   United States of America

We can now completely join the match country data that we just created to the kfc_tidy_data

Lets plot the base map

KFC Animation GIF

KFC Animation gif Now to save the gif to our working directory.

17 Modified Data

##     Country/territory Yearentered Masterfranchisee Country    country year
## 121        Azerbaijan        2018                     <NA> Azerbaijan 2018
## 122            Greece        2018    SSP Hellas SA    <NA>     Greece 2018
## 123            Kosovo        2018     Buçaj Retail    <NA>     Kosovo 2018
## 124           Albania        2019     Buçaj Retail    <NA>    Albania 2019
## 125            Serbia        2020                     <NA>     Serbia 2020
##     spatial_countries      featurecla scalerank labelrank
## 121              <NA> Admin-0 country         1         5
## 122              <NA> Admin-0 country         3         3
## 123              <NA> Admin-0 country         1         6
## 124              <NA> Admin-0 country         1         6
## 125              <NA> Admin-0 country         1         5
##             sovereignt sov_a3 adm0_dif level              type
## 121         Azerbaijan    AZE        0     2 Sovereign country
## 122             Greece    GRC        0     2 Sovereign country
## 123             Kosovo    KOS        0     2 Sovereign country
## 124            Albania    ALB        0     2 Sovereign country
## 125 Republic of Serbia    SRB        0     2 Sovereign country
##                  admin adm0_a3 geou_dif            geounit gu_a3 su_dif
## 121         Azerbaijan     AZE        0         Azerbaijan   AZE      0
## 122             Greece     GRC        0             Greece   GRC      0
## 123             Kosovo     KOS        0             Kosovo   KOS      0
## 124            Albania     ALB        0            Albania   ALB      0
## 125 Republic of Serbia     SRB        0 Republic of Serbia   SRB      0
##                subunit su_a3 brk_diff       name  name_long brk_a3
## 121         Azerbaijan   AZE        0 Azerbaijan Azerbaijan    AZE
## 122             Greece   GRC        0     Greece     Greece    GRC
## 123             Kosovo   KOS        0     Kosovo     Kosovo    KOS
## 124            Albania   ALB        0    Albania    Albania    ALB
## 125 Republic of Serbia   SRB        0     Serbia     Serbia    SRB
##       brk_name brk_group abbrev postal              formal_en formal_fr
## 121 Azerbaijan      <NA>   Aze.     AZ Republic of Azerbaijan      <NA>
## 122     Greece      <NA> Greece     GR      Hellenic Republic      <NA>
## 123     Kosovo      <NA>   Kos.     KO     Republic of Kosovo      <NA>
## 124    Albania      <NA>   Alb.     AL    Republic of Albania      <NA>
## 125     Serbia      <NA>  Serb.     RS     Republic of Serbia      <NA>
##     name_ciawf note_adm0 note_brk  name_sort name_alt mapcolor7 mapcolor8
## 121 Azerbaijan      <NA>     <NA> Azerbaijan     <NA>         1         6
## 122     Greece      <NA>     <NA>     Greece     <NA>         2         2
## 123     Kosovo      <NA>     <NA>     Kosovo     <NA>         2         2
## 124    Albania      <NA>     <NA>    Albania     <NA>         1         4
## 125     Serbia      <NA>     <NA>     Serbia     <NA>         3         3
##     mapcolor9 mapcolor13  pop_est pop_rank gdp_md_est pop_year lastcensus
## 121         5          8  9961396       13     167900     2017       2009
## 122         2          9 10768477       14     290500     2017       2011
## 123         3         11  1895250       12      18490     2017       1981
## 124         1          6  3047987       12      33900     2017       2001
## 125         2         10  7111024       13     101800     2017       2011
##     gdp_year                    economy             income_grp wikipedia
## 121     2016       6. Developing region 3. Upper middle income        NA
## 122     2016 2. Developed region: nonG7   1. High income: OECD        NA
## 123     2016       6. Developing region 4. Lower middle income        NA
## 124     2016       6. Developing region 4. Lower middle income        NA
## 125     2016       6. Developing region 3. Upper middle income        NA
##     fips_10_ iso_a2 iso_a3 iso_a3_eh iso_n3 un_a3 wb_a2 wb_a3   woe_id
## 121       AJ     AZ    AZE       AZE    031   031    AZ   AZE 23424741
## 122       GR     GR    GRC       GRC    300   300    GR   GRC 23424833
## 123       KV     XK   <NA>      <NA>   <NA>  <NA>    KV   KSV      -90
## 124       AL     AL    ALB       ALB    008   008    AL   ALB 23424742
## 125       RI     RS    SRB       SRB    688   688    YF   SRB      -90
##     woe_id_eh
## 121  23424741
## 122  23424833
## 123  29389201
## 124  23424742
## 125  20069818
##                                                                                                woe_note
## 121                                                                          Exact WOE match as country
## 122                                                                          Exact WOE match as country
## 123 Subunit of Serbia in WOE still; should include 29389201, 29389207, 29389218, 29389209 and 29389214.
## 124                                                                          Exact WOE match as country
## 125                                                                   Expired WOE also contains Kosovo.
##     adm0_a3_is adm0_a3_us adm0_a3_un adm0_a3_wb continent region_un
## 121        AZE        AZE         NA         NA      Asia      Asia
## 122        GRC        GRC         NA         NA    Europe    Europe
## 123        KOS        KOS         NA         NA    Europe    Europe
## 124        ALB        ALB         NA         NA    Europe    Europe
## 125        SRB        SRB         NA         NA    Europe    Europe
##           subregion             region_wb name_len long_len abbrev_len
## 121    Western Asia Europe & Central Asia       10       10          4
## 122 Southern Europe Europe & Central Asia        6        6          6
## 123 Southern Europe Europe & Central Asia        6        6          4
## 124 Southern Europe Europe & Central Asia        7        7          4
## 125 Southern Europe Europe & Central Asia        6        6          5
##     tiny homepart min_zoom min_label max_label      ne_id wikidataid
## 121   NA        1        0         4         9 1159320381       Q227
## 122   NA        1        0         3         8 1159320811        Q41
## 123   NA        1        0         5        10 1159321007      Q1246
## 124   NA        1        0         5        10 1159320325       Q222
## 125   NA        1        0         4         7 1159321267       Q403
##     name_ar name_bn       name_de    name_es     name_fr name_el name_hi
## 121    <NA>    <NA> Aserbaidschan Azerbaiyán Azerbaïdjan    <NA>    <NA>
## 122    <NA>    <NA>  Griechenland     Grecia       Grèce    <NA>    <NA>
## 123    <NA>    <NA>        Kosovo     Kosovo      Kosovo    <NA>    <NA>
## 124    <NA>    <NA>      Albanien    Albania     Albanie    <NA>    <NA>
## 125    <NA>    <NA>       Serbien     Serbia      Serbie    <NA>    <NA>
##          name_hu    name_id     name_it name_ja name_ko      name_nl
## 121 Azerbajdzsán Azerbaijan Azerbaigian    <NA>    <NA> Azerbeidzjan
## 122  Görögország     Yunani      Grecia    <NA>    <NA>  Griekenland
## 123      Koszovó     Kosovo      Kosovo    <NA>    <NA>       Kosovo
## 124      Albánia    Albania     Albania    <NA>    <NA>      Albanië
## 125      Szerbia     Serbia      Serbia    <NA>    <NA>       Servië
##         name_pl    name_pt name_ru      name_sv    name_tr    name_vi
## 121 Azerbejdzan Azerbaijão    <NA> Azerbajdzjan Azerbaycan Azerbaijan
## 122      Grecja     Grécia    <NA>     Grekland Yunanistan       <NA>
## 123      Kosowo     Kosovo    <NA>       Kosovo     Kosova     Kosovo
## 124     Albania    Albânia    <NA>     Albanien Arnavutluk    Albania
## 125      Serbia     Sérvia    <NA>      Serbien  Sirbistan     Serbia
##     name_zh                       geometry
## 121    <NA> MULTIPOLYGON (((44.81719 39...
## 122    <NA> MULTIPOLYGON (((27.86016 36...
## 123    <NA> MULTIPOLYGON (((20.34434 42...
## 124    <NA> MULTIPOLYGON (((19.34238 41...
## 125    <NA> MULTIPOLYGON (((21.36006 44...

18 Modified Mac

##    x date_of_first_store first_outlet_location
## 1 NA                <NA>                  <NA>
## 2 NA                <NA>                  <NA>
##   number_of_currently_operating_outlets source_and_date_of_source
## 1                                  <NA>                      <NA>
## 2                                  <NA>                      <NA>
##   people_per_outlet country year spatial_countries featurecla scalerank
## 1              <NA>    <NA> 1930              <NA>       <NA>        NA
## 2              <NA>    <NA> 1931              <NA>       <NA>        NA
##   labelrank sovereignt sov_a3 adm0_dif level type admin adm0_a3 geou_dif
## 1        NA       <NA>   <NA>       NA    NA <NA>  <NA>    <NA>       NA
## 2        NA       <NA>   <NA>       NA    NA <NA>  <NA>    <NA>       NA
##   geounit gu_a3 su_dif subunit su_a3 brk_diff name name_long brk_a3
## 1    <NA>  <NA>     NA    <NA>  <NA>       NA <NA>      <NA>   <NA>
## 2    <NA>  <NA>     NA    <NA>  <NA>       NA <NA>      <NA>   <NA>
##   brk_name brk_group abbrev postal formal_en formal_fr name_ciawf
## 1     <NA>      <NA>   <NA>   <NA>      <NA>      <NA>       <NA>
## 2     <NA>      <NA>   <NA>   <NA>      <NA>      <NA>       <NA>
##   note_adm0 note_brk name_sort name_alt mapcolor7 mapcolor8 mapcolor9
## 1      <NA>     <NA>      <NA>     <NA>        NA        NA        NA
## 2      <NA>     <NA>      <NA>     <NA>        NA        NA        NA
##   mapcolor13 pop_est pop_rank gdp_md_est pop_year lastcensus gdp_year
## 1         NA    <NA>       NA         NA       NA         NA       NA
## 2         NA    <NA>       NA         NA       NA         NA       NA
##   economy income_grp wikipedia fips_10_ iso_a2 iso_a3 iso_a3_eh iso_n3
## 1    <NA>       <NA>        NA     <NA>   <NA>   <NA>      <NA>   <NA>
## 2    <NA>       <NA>        NA     <NA>   <NA>   <NA>      <NA>   <NA>
##   un_a3 wb_a2 wb_a3 woe_id woe_id_eh woe_note adm0_a3_is adm0_a3_us
## 1  <NA>  <NA>  <NA>     NA        NA     <NA>       <NA>       <NA>
## 2  <NA>  <NA>  <NA>     NA        NA     <NA>       <NA>       <NA>
##   adm0_a3_un adm0_a3_wb continent region_un subregion region_wb name_len
## 1         NA         NA      <NA>      <NA>      <NA>      <NA>       NA
## 2         NA         NA      <NA>      <NA>      <NA>      <NA>       NA
##   long_len abbrev_len tiny homepart min_zoom min_label max_label ne_id
## 1       NA         NA   NA       NA       NA        NA        NA  <NA>
## 2       NA         NA   NA       NA       NA        NA        NA  <NA>
##   wikidataid name_ar name_bn name_de name_es name_fr name_el name_hi
## 1       <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 2       <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
##   name_hu name_id name_it name_ja name_ko name_nl name_pl name_pt name_ru
## 1    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 2    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
##   name_sv name_tr name_vi name_zh           geometry
## 1    <NA>    <NA>    <NA>    <NA> MULTIPOLYGON EMPTY
## 2    <NA>    <NA>    <NA>    <NA> MULTIPOLYGON EMPTY
##       x date_of_first_store first_outlet_location
## 127 117    February 8, 2014      Ho Chi Minh City
## 128 118       March 8, 2016            Nur-Sultan
##     number_of_currently_operating_outlets source_and_date_of_source
## 127                                    17            (source: 2017)
## 128                                    14                          
##     people_per_outlet    country year spatial_countries      featurecla
## 127         5,620,000    Vietnam 2014              <NA> Admin-0 country
## 128         1,288,571 Kazakhstan 2016              <NA> Admin-0 country
##     scalerank labelrank sovereignt sov_a3 adm0_dif level              type
## 127         3         2    Vietnam    VNM        0     2 Sovereign country
## 128         5         3 Kazakhstan    KAZ        0     2 Sovereign country
##          admin adm0_a3 geou_dif    geounit gu_a3 su_dif    subunit su_a3
## 127    Vietnam     VNM        0    Vietnam   VNM      0    Vietnam   VNM
## 128 Kazakhstan     KAZ        0 Kazakhstan   KAZ      0 Kazakhstan   KAZ
##     brk_diff       name  name_long brk_a3   brk_name brk_group abbrev
## 127        0    Vietnam    Vietnam    VNM    Vietnam      <NA>  Viet.
## 128        0 Kazakhstan Kazakhstan    KAZ Kazakhstan      <NA>   Kaz.
##     postal                     formal_en formal_fr name_ciawf note_adm0
## 127     VN Socialist Republic of Vietnam      <NA>    Vietnam      <NA>
## 128     KZ        Republic of Kazakhstan      <NA> Kazakhstan      <NA>
##     note_brk  name_sort name_alt mapcolor7 mapcolor8 mapcolor9 mapcolor13
## 127     <NA>    Vietnam     <NA>         5         6         5          4
## 128     <NA> Kazakhstan     <NA>         6         1         6          1
##      pop_est pop_rank gdp_md_est pop_year lastcensus gdp_year
## 127 96160163       16     594900     2017       2009     2016
## 128 18556698       14     460700     2017       2009     2016
##                     economy             income_grp wikipedia fips_10_
## 127 5. Emerging region: G20 4. Lower middle income        NA       VM
## 128    6. Developing region 3. Upper middle income        NA       KZ
##     iso_a2 iso_a3 iso_a3_eh iso_n3 un_a3 wb_a2 wb_a3   woe_id woe_id_eh
## 127     VN    VNM       VNM    704   704    VN   VNM 23424984  23424984
## 128     KZ    KAZ       KAZ    398   398    KZ   KAZ      -90  23424871
##                                       woe_note adm0_a3_is adm0_a3_us
## 127                 Exact WOE match as country        VNM        VNM
## 128 Includes Baykonur Cosmodrome as an admin-1        KAZ        KAZ
##     adm0_a3_un adm0_a3_wb continent region_un          subregion
## 127         NA         NA      Asia      Asia South-Eastern Asia
## 128         NA         NA      Asia      Asia       Central Asia
##                 region_wb name_len long_len abbrev_len tiny homepart
## 127   East Asia & Pacific        7        7          5    2        1
## 128 Europe & Central Asia       10       10          4   NA        1
##     min_zoom min_label max_label      ne_id wikidataid name_ar name_bn
## 127        0         2         7 1159321417       Q881    <NA>    <NA>
## 128        0         3         7 1159320967       Q232    <NA>    <NA>
##        name_de    name_es    name_fr name_el name_hi    name_hu    name_id
## 127    Vietnam    Vietnam   Viêt Nam    <NA>    <NA>    Vietnám    Vietnam
## 128 Kasachstan Kazajistán Kazakhstan    <NA>    <NA> Kazahsztán Kazakhstan
##        name_it name_ja name_ko    name_nl    name_pl     name_pt name_ru
## 127    Vietnam    <NA>    <NA>    Vietnam    Wietnam    Vietname    <NA>
## 128 Kazakistan    <NA>    <NA> Kazachstan Kazachstan Cazaquistão    <NA>
##       name_sv    name_tr    name_vi name_zh                       geometry
## 127   Vietnam    Vietnam       <NA>    <NA> MULTIPOLYGON (((104.064 10....
## 128 Kazakstan Kazakistan Kazakhstan    <NA> MULTIPOLYGON (((50.18447 44...
##      x date_of_first_store first_outlet_location
## 130 NA                <NA>                  <NA>
## 131 NA                <NA>                  <NA>
##     number_of_currently_operating_outlets source_and_date_of_source
## 130                                  <NA>                      <NA>
## 131                                  <NA>                      <NA>
##     people_per_outlet country year spatial_countries featurecla scalerank
## 130              <NA>    <NA> 2018              <NA>       <NA>        NA
## 131              <NA>    <NA> 2019              <NA>       <NA>        NA
##     labelrank sovereignt sov_a3 adm0_dif level type admin adm0_a3 geou_dif
## 130        NA       <NA>   <NA>       NA    NA <NA>  <NA>    <NA>       NA
## 131        NA       <NA>   <NA>       NA    NA <NA>  <NA>    <NA>       NA
##     geounit gu_a3 su_dif subunit su_a3 brk_diff name name_long brk_a3
## 130    <NA>  <NA>     NA    <NA>  <NA>       NA <NA>      <NA>   <NA>
## 131    <NA>  <NA>     NA    <NA>  <NA>       NA <NA>      <NA>   <NA>
##     brk_name brk_group abbrev postal formal_en formal_fr name_ciawf
## 130     <NA>      <NA>   <NA>   <NA>      <NA>      <NA>       <NA>
## 131     <NA>      <NA>   <NA>   <NA>      <NA>      <NA>       <NA>
##     note_adm0 note_brk name_sort name_alt mapcolor7 mapcolor8 mapcolor9
## 130      <NA>     <NA>      <NA>     <NA>        NA        NA        NA
## 131      <NA>     <NA>      <NA>     <NA>        NA        NA        NA
##     mapcolor13 pop_est pop_rank gdp_md_est pop_year lastcensus gdp_year
## 130         NA    <NA>       NA         NA       NA         NA       NA
## 131         NA    <NA>       NA         NA       NA         NA       NA
##     economy income_grp wikipedia fips_10_ iso_a2 iso_a3 iso_a3_eh iso_n3
## 130    <NA>       <NA>        NA     <NA>   <NA>   <NA>      <NA>   <NA>
## 131    <NA>       <NA>        NA     <NA>   <NA>   <NA>      <NA>   <NA>
##     un_a3 wb_a2 wb_a3 woe_id woe_id_eh woe_note adm0_a3_is adm0_a3_us
## 130  <NA>  <NA>  <NA>     NA        NA     <NA>       <NA>       <NA>
## 131  <NA>  <NA>  <NA>     NA        NA     <NA>       <NA>       <NA>
##     adm0_a3_un adm0_a3_wb continent region_un subregion region_wb name_len
## 130         NA         NA      <NA>      <NA>      <NA>      <NA>       NA
## 131         NA         NA      <NA>      <NA>      <NA>      <NA>       NA
##     long_len abbrev_len tiny homepart min_zoom min_label max_label ne_id
## 130       NA         NA   NA       NA       NA        NA        NA  <NA>
## 131       NA         NA   NA       NA       NA        NA        NA  <NA>
##     wikidataid name_ar name_bn name_de name_es name_fr name_el name_hi
## 130       <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 131       <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
##     name_hu name_id name_it name_ja name_ko name_nl name_pl name_pt
## 130    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
## 131    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>
##     name_ru name_sv name_tr name_vi name_zh           geometry
## 130    <NA>    <NA>    <NA>    <NA>    <NA> MULTIPOLYGON EMPTY
## 131    <NA>    <NA>    <NA>    <NA>    <NA> MULTIPOLYGON EMPTY
Thank You

Thank You