Visualizing Globalization

I made a post about my McDonald's visualization on r/dataisbeautiful and received feedback in the form of Reddit comments about areas to improve on for a more effective visualization.

One thing led to another, and now armed with knowledge of basic Wikipedia scraping and R, I set out to visualize the spread of more companies.

Inspiration

Multiple commenters mentioned an interesting correlation between globalization and the rate of expansion into other countries. This made me wonder if a company in the same sector like KFC would have the same expansion pattern.

With a couple modifications to handle exceptions and formatting in each case, my existing code could scrape any page with a HTML table showing the expansion timeline. After KFC, I got to analyzing IKEA, Spotify and Apple Stores.

Process

The script for these visualizations is based on my initial program. The KFC Wikipedia page separates the expansion into different regions. I had to use a function to iterate over all the tables and then combine them.

I made the Spotify plot next. All the countries that Spotify expanded to were grouped by date, so I used the separate_rows() function to split each country into its own row.

For IKEA and Apple Stores, the process was very similar. The data was read in, tidied up, then corrected for any mismatches and exceptions.

Challenges

Since I based these off my existing code, there were no challenges in making them. The only variation was in the format of the data sets. However, I had to abandon plotting expansion over month due to trouble with implementation.

Spotify is a recent company, so I originally planned to plot the expansion of Spotify by month instead of year. However, I had difficulty getting my plotting function to iterate by month. Checking the month and year value before plotting also posed a problem.

Accomplishments

  • Got familiar with scraping, manipulating, and plotting data with R
  • Used the rvest library to scrape a HTML table
  • Manipulated data for plotting with stringr package and the tidyverse library
  • Plotted the map with rnaturalearth, sf and glue libraries
  • Adapted existing code in each instance to handle exceptions and change in formattin

Future Plans

Be able to visualize interesting relationships and concepts in different units (months, days). Also to animate different kinds of data other than geographical expansion in R. I also hope to become more familiar with animated visualizations.