title: Why I get this error writing data to a file
body: <p>I have this code</p>
  
  <pre><code>myvector &lt;- c(3.45235, 1.32525, ... , 2.41351)    # some numbers
  write(myvector, "C:/mypath/myfile.txt")           # I use "/" instead of "\"
  </code></pre>
  
  <p>and I get the following error:</p>
  
  <blockquote>
    <p>Error in file(file, ifelse(append, "a", "w")) :    cannot open the
    connection In addition: warning message: In file(file, ifelse(append,
    "a", "w")) :    cannot open file 'C:/mypath/myfile.txt' : No such file
    or directory</p>
  </blockquote>
  
  <p>I read <a href="http://stat.ethz.ch/R-manual/R-patched/library/base/html/write.html" rel="noreferrer">this tutorial</a>, but I can't understant what's wrong with my code. Any idea?</p>
  
  <p><strong>edit</strong>:</p>
  
  <p>As @dickoa pointed out, I need an existing path to write a file, so I tried to simplify in the following way:</p>
  
  <pre><code>file.exists("C:/")
  write(myvector, "C:/myfile.txt")
  </code></pre>
  
  <p><em>Surprisingly</em> :P the path "C:/" exists (the result is TRUE) but I get a similar error:</p>
  
  <blockquote>
    <p>Error in file(file, ifelse(append, "a", "w")) :    cannot open the
    connection 
    In addition: warning message: In file(file, ifelse(append,
    "a", "w")) :    cannot open file 'C:/mypath/myfile.txt' : Permission denied</p>
  </blockquote>