
Go to: [Data Set index]
IntroductionThis document contains R code that can be used to transform twomode service value matrices (svm) into onemode intercity connectivity matrices (icc) using the interlocking network model (inm) (Taylor, 2001), and subsequently compute the global network connectivity (gnc) for every city. Details on the input matrices, the model, and its output can be found in Taylor and Derudder (2016). R is a free software environment that provides a wide variety of statistical techniques. R needs to be downloaded, together with a development environment that supports direct code execution, and tools for plotting, history, debugging and workspace management. We used Rstudio and generated this document with R Markdown. R Markdown is designed for easier reproducibility, because both computing code and narratives are in the same document. The code runs with the “dplyr”package. The below example refers to the 2018 data as shown by the file names, but the code works with any other service value matrix in .csvformat as long as it is properly structured. Basically, three steps are explained in this brief guide: (i) creating a numerical service value matrix; (ii) computing the intercity connectivity matrix and (iii) generating a table with global network connectivities. Step 1  Creating a numerical service value matrixFirst of all, GaWC’s twomode service value matrix needs to be read and stored. Data are stored in a dataframe called ‘svm’ with the following code:
A dataframe can contain characters, strings and numbers, and is therefore not fit for matrix algebra. We extract the cities and firms from the dataframe and transform what is left into a numerical matrix ‘svm_mat’ (dimensions: 175 firms x 707 cities) as follows:
Step 2  Constructing intercity connectivity matrixThe icc matrix is basically the product of the svm matrix and its transpose (Derudder, 2020). This can easily be done with the tcrossprodfunction. Keep in mind that the diagonals are zero.
Step 3  Calculating global network connectivity for every cityTo calculate absolute and relative global network connectivity for every city, we use code that calculates the total iccvalue for every city (which is the absolute GNCvalue), and sorts the output. We add a GNC_rel value and a rank to the table.
^{* }Tom Storme and Ben Derudder, SEG Research Group, Ghent University, 1 April 2020 
