title: how to change NA-s to empty cells in R
body: <p>I have a data frame with varying number of columns (depending on the year I have fewer or more data points). Originally this is a cross-sectional time series long dataset rather than a wide dataset but I need to pull out a vector for each year from it (and I would like to create country tables). </p>
  
  <p>At the moment R puts <code>NA</code>s at the end of the rows if I have fewer data points (which means that some of the end columns have NA-s). </p>
  
  <p>However I would like to use each row as an input vector in a Python code that does not like <code>NA</code>s. So I would like to replace the <code>NA</code>s with empty cells. It would be ideal to have different length vectors. Replacing the <code>NA</code>s with zeros does not work either since I would like to keep track of the different row sizes for different years. I have found answers for characters but I have numbers, any help would be appreciated. 
  The goal is to write a table or csv file without the NA-s, as I would like to pass each row in a python code.<br>
  Thank you! </p>
  
  <pre><code> mat1 &lt;- matrix(c(3,0, 1, 13, NA, NA,NA, 3, 0, 1, 13, 
                    NA, NA, NA, 3, 0 ,1 ,16, NA, NA, NA,
                    3,0, 1, 16, NA, NA, NA, 0, 0, 134, 33, 39, 1, 14,    
                    0,0, 134, 33, 39, 1, 14),7,6)
  print(t(mat1))
       [,1] [,2] [,3] [,4] [,5] [,6] [,7]
   [1,]    3    0    1   13   NA   NA   NA
   [2,]    3    0    1   13   NA   NA   NA
   [3,]    3    0    1   16   NA   NA   NA
   [4,]    3    0    1   16   NA   NA   NA
   [5,]    0    0  134   33   39    1   14
   [6,]    0    0  134   33   39    1   14
  </code></pre>
  
  <p>As a data.frame:</p>
  
  <pre><code>&gt; print(as.data.frame(t(mat1)))
   &gt;    V1 V2 V3 V4 V5 V6 V7
   &gt; 1  3  0   1 13 NA NA NA
   &gt; 2  3  0   1 13 NA NA NA
   &gt; 3  3  0   1 16 NA NA NA
   &gt; 4  3  0   1 16 NA NA NA
   &gt; 5  0  0 134 33 39  1 14
   &gt; 6  0  0 134 33 39  1 14
  </code></pre>