title: Error in file(filename, "r", encoding = encoding) : cannot open the connection
body: <p>I have an <code>RScript</code> file (let's call it <code>main.r</code>) which has a reference to another file, using the below code:</p>
  <pre><code>source(&quot;functions.R&quot;)
  </code></pre>
  <p>But, when I run the RScript file, it complains with the below error:</p>
  <pre><code>    Error in file(filename, &quot;r&quot;, encoding = encoding) : 
        cannot open the connection
      In addition: Warning message:
      In file(filename, &quot;r&quot;, encoding = encoding) :
        cannot open file 'functions.R': No such file or directory
  </code></pre>
  <p>I am sure, my <code>main.R</code> file is next to <code>functions.R</code> in the same directory.
  I can call the <code>functions.R</code> in the <code>Rmd</code> (<code>RMarkdown</code>) file which exist in the same directory</p>