title: How to run an R script file from the command line
body: <p>I know there are a lot of questions regarding this issue but I've tried everything and I think I just don't understand how the command line works in windows. I have a file saved in a folder on my desktop, let's say:</p>
  
  <pre><code>C:\Users\abika_000\Desktop\R models\myfile.R
  </code></pre>
  
  <p>Here is the directory to my R/bin or Rscript/bin:</p>
  
  <pre><code>C:\Program Files\R\R-3.1.0\bin
  </code></pre>
  
  <p>I want to run this code using the cmd prompt. How would I go about doing this?</p>
  
  <p>I've tried this solution from the question below but I just keep getting errors no matter what I do:</p>
  
  <p><a href="https://stackoverflow.com/questions/18306362/run-r-script-from-command-line">Run R script from command line</a></p>
  
  <p>What I entered:</p>
  
  <pre><code>&gt; R CMD BATCH C:\Users\abika_000\Desktop\R models\myfile.R
  &gt; Rscript C:\Users\abika_000\Desktop\R models\myfile.R
  </code></pre>
  
  <p>The errors I get are:</p>
  
  <pre><code>'R' is not recognized as an internal or external command, operable program or batch file
  'Rscript' is not recognized as an internal or external command, operable program or batch file
  </code></pre>
  
  <p>EDIT::</p>
  
  <p>Credit to splendour and Phil. I wound up fixing it by entering:</p>
  
  <pre><code>&gt; "C:\Program Files\R\R-3.1.0\bin\"R CMD BATCH "C:\Users\abika_000\Desktop\R models\myfile.R"
  </code></pre>
  
  <p>I apologize for the poor question. I just wasn't sure how to use the cmd prompt /directories in trying to use R CMD BATCH or Rscript</p>