title: Error in approxfun, need at least two non-NA values to interpolate
body: <p>I'm trying to use approxfun to calculate missing value using interpolate:</p>
  
  <pre><code>column_name &lt;- colnames(vndusd_merged);
  
  lapply(column_name, function(x){
    if(x != "Date"){ 
      interpl &lt;- approxfun(vndusd_merged$Date[!is.na(vndusd_merged$x)], vndusd_merged$x[!is.na(vndusd_merged$x)]);
      vndusd_merged$x &lt;- interpl(vndusd_merged$Date);  
    }
  })
  </code></pre>
  
  <p>I keep  getting this error:</p>
  
  <pre><code>Error in approxfun(vndusd_merged$Date[!is.na(vndusd_merged$x)], vndusd_merged$x[!is.na(vndusd_merged$x)]) : 
    need at least two non-NA values to interpolate 
  4.
  stop("need at least two non-NA values to interpolate") 
  3.
  approxfun(vndusd_merged$Date[!is.na(vndusd_merged$x)], vndusd_merged$x[!is.na(vndusd_merged$x)]) 
  2.
  FUN(X[[i]], ...) 
  1.
  lapply(column_name, function(x) {
      if (x != "Date") {
          interpl &lt;- approxfun(vndusd_merged$Date[!is.na(vndusd_merged$x)], 
              vndusd_merged$x[!is.na(vndusd_merged$x)]) ... 
  </code></pre>
  
  <p>Here are the sample of the first 20 row of <code>vndusd_merged</code>. The column "Date" does not have any N/A</p>
  
  <pre><code>         Date Ask.Close Bid.Close
  1  01/01/2014     21115     21075
  2  02/01/2014     21160     21060
  3  03/01/2014     21115     21075
  4  04/01/2014        NA        NA
  5  05/01/2014        NA        NA
  6  06/01/2014     21120     21080
  7  07/01/2014     21115     21075
  8  08/01/2014     21120     21080
  9  09/01/2014     21115     21075
  10 10/01/2014     21110     21072
  11 11/01/2014        NA        NA
  12 12/01/2014        NA        NA
  13 13/01/2014     21120     21060
  14 14/01/2014     21110     21072
  15 15/01/2014     21110     21070
  16 16/01/2014     21120     21080
  17 17/01/2014     21110     21070
  18 18/01/2014        NA        NA
  19 19/01/2014        NA        NA
  20 20/01/2014     21110     21070
  </code></pre>
  
  <p>I tried to run it by inserting the column name manually but I still got the same error.</p>
  
  <pre><code>interpl &lt;- aproxfun(vndusd_merged$Date[!is.na(vndusd_merged$Ask.Close)], vndusd_merged$Ask.Close[!is.na(vndusd_merged$Ask.Close)]);
  </code></pre>
  
  <p>How can I solve this problem?</p>