title: calling an Rscript from node.js
body: <p>I have been trying to execute an Rscript from my node.js server. tried to follow an example online, but i keep getting a null returned object or sometimes the process keeps running forever. I have mentioned the code snippet below. Thank you.</p>
  
  <p>example.js ::</p>
  
  <pre><code>var R = require("r-script");
  
  
  var out = R("scripts/testScript.R")
          .data("hello world", 20)
          .callSync(function(err,resp){
                        console.log(out);
                     });
  </code></pre>
  
  <p>testScript.R file :::</p>
  
  <pre><code>needs(magrittr)
  set.seed(512)
  do.call(rep, input) %&gt;% 
  strsplit(NULL) %&gt;% 
  sapply(sample) %&gt;% 
  apply(2, paste, collapse = "")
  </code></pre>