Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Make sure all variables are defined in the same environment as <code>getSetOrderData</code>? I find that if I define</p> <pre><code>fsub &lt;- function( x ){ return( x^2 ) } fmain &lt;- function( x ){ x &lt;- fsub( x ) + 2 return(x) } </code></pre> <p>And then I use them thus:</p> <pre><code>require(doParallel) cl &lt;- makeCluster( 2 , outfile = "" ) registerDoParallel( cl ) foreach( k = 1:2 , .verbose = TRUE , .combine = c ) %dopar%{ fmain( k ) } </code></pre> <p>I get results as I expected:</p> <pre><code>numValues: 2, numResults: 0, stopped: TRUE automatically exporting the following variables from the local environment: fmain, fsub got results for task 1 numValues: 2, numResults: 1, stopped: TRUE returning status FALSE got results for task 2 numValues: 2, numResults: 2, stopped: TRUE first call to combine function evaluating call object to combine results: fun(result.1, result.2) returning status TRUE [1] 3 6 </code></pre> <p>And further, if I call the functions - which are not otherwise defined inside the <code>.GlobalEnv</code>- inside another function using <code>source()</code> it still works. Let's say I make a script called <code>util_funcs.R</code> inside my home directory and paste those two functions in, but call them <code>fsub2</code> and <code>fmain2</code>. If I call it in the following way:</p> <pre><code>fsource &lt;- function( x ){ source( "~/util_funcs.R" ) x &lt;- fmain2( x ) return( x ) } </code></pre> <p>It still works:</p> <pre><code>numValues: 2, numResults: 0, stopped: TRUE automatically exporting the following variables from the local environment: fsource got results for task 1 numValues: 2, numResults: 1, stopped: TRUE returning status FALSE got results for task 2 numValues: 2, numResults: 2, stopped: TRUE first call to combine function evaluating call object to combine results: fun(result.1, result.2) returning status TRUE [1] 3 6 </code></pre> <p>Can you just copy/paste all the functions in a simple R script and use <code>source()</code>?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload