title: Apply na.approx on row and output dataframe in R
body: <p>Given the following dataframe:</p>
  <pre><code>df1 &lt;- data.frame(Company = c('A','B','C','D','E'), `X1980` = c(NA, 5, 3, 8, 13),
                                  `X1981` = c(20, NA, 23, 11, 29),
                                  `X1982` = c(NA, 32, NA, 41, 42),
                                  `X1983` = c(45, 47, 53, 58, NA))
  </code></pre>
  <p>I would like to replace the NA's with values through interpolation over the rows resulting in the following data frame:</p>
  <pre><code>Company  1980  1981  1982  1983
     A      NA    20   32,5   45
     B      5    18,5   32    47
     C      3     23    38    53
     D      8     11    41    58
     E      13    29    42    NA
  </code></pre>
  <p>I tried using na.apporox in combination with apply:</p>
  <pre><code>df1[-1] &lt;- t(apply(df1[-1], 1, FUN = na.approx))
  </code></pre>
  <p>But this results in the following error:</p>
  <pre><code>Fehler in h(simpleError(msg, call)) : 
    Fehler bei der Auswertung des Argumentes 'x' bei der Methodenauswahl für Funktion 't': dim(X) muss positive Länge haben
  </code></pre>
  <p>Thanks in advance for any help!!!</p>
  <p>EDIT:
  I forgot to define how to treat the NA's in the na.approx function.</p>
  <pre><code>df1[-1] &lt;- t(apply(df1[-1], 1, na.approx, na.rm=FALSE))
  </code></pre>
  <p>This results in the desired output!</p>