title: Why can't the future package find my function?
body: <p>I asked a similar question earlier today but @MrFlick found a problem with my reproducible example. Now I have another reproducible example, and I think this one works.</p>
  <p>The problem is that the future package cannot see one of my functions. I also tried with foreach and it has the same problem: it cannot see the same function. So here is the code:</p>
  <pre><code>library(&quot;future&quot;)
  library(&quot;tidyverse&quot;)
  library(&quot;rlist&quot;)
  
  aspect.major.names &lt;- c(&quot;Conjunction&quot;, &quot;Opposition&quot;, &quot;Trine&quot;, &quot;Square&quot;, &quot;Sextile&quot;)
  
  aspect_strength &lt;- function(angle, center=0, orb=8) {
    abs_angle &lt;- abs(angle)
    calculated_angle &lt;- if (abs_angle &gt;= center - orb &amp;&amp; abs_angle &lt;= center + orb) {
      abs_angle
    } else {
      abs_angle_360 &lt;- 360 - abs_angle
      if (abs_angle_360 &gt;= center - orb &amp;&amp; abs_angle_360 &lt;= center + orb) {
        abs_angle_360} else {-1}
    }
    if (calculated_angle &lt; 0) {return(0)}
  
    1 - abs(calculated_angle - center)/orb
  }
  
  conjunction_func &lt;- function(x) aspect_strength(x, 0, conjunction_orb)
  conjunction_strength &lt;- function(x) sapply(x, conjunction_func)
  sextile_func &lt;- function(x) aspect_strength(x, 60, sextile_orb)
  sextile_strength &lt;- function(x) sapply(x, sextile_func)
  square_func &lt;- function(x) aspect_strength(x, 90, square_orb)
  square_strength &lt;- function(x) sapply(x, square_func)
  trine_func &lt;- function(x) aspect_strength(x, 120, trine_orb)
  trine_strength &lt;- function(x) sapply(x, trine_func)
  opposition_func &lt;- function(x) aspect_strength(x, 180, opposition_orb)
  opposition_strength &lt;- function(x) sapply(x, opposition_func)
  
  strength_funcs &lt;- c(conjunction_strength, opposition_strength,
                      trine_strength, square_strength, sextile_strength)
  names(strength_funcs) &lt;- aspect.major.names
  
  smoa &lt;- c(15.402917, 29.143750, 42.892500, 56.533333, 69.970417, 83.142083, 96.012500, 108.580000, 120.861667, 132.891667)
  smea &lt;- c(339.32542, 339.63667, 339.96375, 340.30792, 340.67208, 341.04917, 341.44333, 341.85042, 342.26750, 342.70167)
  df_angles &lt;- data.frame(Sun_Moon_Angle = smoa, Sun_Mercury_Angle = smea)
  
  orb &lt;- 8
  conjunction_orb &lt;- sextile_orb &lt;- square_orb &lt;- trine_orb &lt;- opposition_orb &lt;- orb
  
  csma &lt;- function(asp) {
  
    # This is needed otherwise there is an error
    # conjunction_func
    # opposition_func
    # trine_func
    # square_func
    # sextile_func
  
    df_angles %&gt;%
      apply(2, strength_funcs[[asp]]) %&gt;%
      as.data.frame() -&gt; df_strength
    df_strength
  }
  
  plan(sequential)
  plan(multisession, workers=6)
  futs &lt;- lapply(aspect.major.names, function(x) future({ csma(x) }))
  lapply(futs, value) %&gt;% list.cbind() -&gt; dfsmas
  </code></pre>
  <p>When I run this code I get the following message:</p>
  <pre><code>lapply(futs, value) %&gt;% list.cbind() -&gt; dfsmas
  Error in match.fun(FUN) : object 'conjunction_func' not found
  </code></pre>
  <p>The first lapply executes with no problems. It is in the second one, which calls the value function, that the error occurs.</p>
  <p>What is odd (at least to me) is that if one uncomments these lines within the csma function the code works and there is no error.</p>
  <pre><code>  # conjunction_func
    # opposition_func
    # trine_func
    # square_func
    # sextile_func
  </code></pre>
  <p>Uncommented, these lines seem to remind future that these functions exist.</p>