title: Parallel computing, which alternative to tidyr::complete in dplyr?
body: <p>I am trying to parallelise a pipe.
  In the pipe there is a tidyr command (&quot;tidyr::complete&quot;). This breaks down the code once run in parallel, as the object class is not recognised.</p>
  <p>Is there an alternative in dplyr to complete?</p>
  <pre><code>library(dplyr)
  library(tidyr)
  library(zoo)
  
  
  test &lt;- tibble(year=c(1,2,3,4,5,5,1,4,5),
                 var_1=c(1,1,1,1,1,1,2,2,2), 
                 var_2=c(1,1,1,1,1,2,3,3,3), 
                 var_3=c(0,5,NA,15,20,NA,1,NA,NA))
  
  max_year &lt;- max(test$year,na.rm = T)
  min_year &lt;- min(test$year,na.rm = T)
  
  </code></pre>
  <p><strong>SERIAL</strong></p>
  <pre><code>
  test_serial &lt;- test %&gt;% 
    group_by(var_1,var_2) %&gt;% 
    complete(var_1, year = seq(min_year,max_year)) %&gt;%
    mutate(
      var_3 = na.approx(var_3,na.rm = FALSE),
      var_3 = if(all(is.na(var_3))) NA else na.spline(var_3,na.rm = FALSE))
  
  
  </code></pre>
  <p><strong>PARALLEL</strong> (THIS FAILS)</p>
  <pre><code>devtools::install_github(&quot;hadley/multidplyr&quot;)
  library(multidplyr)
  
  cl &lt;- new_cluster(2)
  cluster_copy(cl, c(&quot;test&quot;,&quot;max_year&quot;,&quot;min_year&quot;))
  cluster_library(cl, c(&quot;dplyr&quot;,&quot;tidyr&quot;,&quot;zoo&quot;))
  
  test_parallel &lt;- test %&gt;% group_by(var_1,var_2) %&gt;% partition(cl)
  test_parallel &lt;- test_parallel %&gt;% 
    dplyr::group_by(var_1,var_2) %&gt;% 
    tidyr::complete(var_1, year = seq(min_year,max_year)) %&gt;%
    dplyr::mutate(
      var_3 = na.approx(var_3,na.rm = FALSE),
      var_3 = if(all(is.na(var_3))) NA else na.spline(var_3,na.rm = FALSE)) %&gt;% 
    collect()
  
  </code></pre>
  <p>This is the error message</p>
  <pre><code>Error in UseMethod(&quot;complete_&quot;) : 
    no applicable method for 'complete_' applied to an object of class &quot;multidplyr_party_df&quot;
  </code></pre>