title: Create a list of distance matrices in R
body: <p>Using the Cshapes package in R, I want to create a list of matrices that measure for each year whether two countries are neigbors or not.</p>
  
  <pre><code>install.packages("cshapes")
  </code></pre>
  
  <p>Running the code for one year (here 1990) works fine:</p>
  
  <p><code>wmat &lt;- distmatrix(as.Date("1990-1-1"), type="mindist", tolerance=0.5, useGW=FALSE)</code></p>
  
  <p>This gives a matrix with the following structure:</p>
  
  <pre><code>        A   B   C   D
  1   A   0   0   210 0
  2   B   0   0   637 305
  3   C   210 637 0   73
  4   D   0   305 73  0
  </code></pre>
  
  <p>In a next step, I set all combinations with 0 distance between two countries to 1, all other combinations to 0, and the diagonal to 0 again:</p>
  
  <pre><code>wmat[wmat&gt;0]&lt;-5
  wmat[wmat==0]&lt;-1
  wmat[wmat==5]&lt;-0
  diag(wmat)&lt;-0
  </code></pre>
  
  <p>This gives me following matrix:</p>
  
  <pre><code>        A   B   C   D
  1   A   0   1   0   1
  2   B   1   0   0   0
  3   C   0   0   0   0
  4   D   1   0   0   0
  </code></pre>
  
  <p>What I struggle to do is to automatically create matrices for all the years between 1960 and 2014, do the corrections for each year and store the results into a list of matrices where I can recall each matrix by the respective year.</p>
  
  <p>Any inputs are highly welcome.</p>