title: Return code of successful or failed write.table in R
body: <p><strong>Question:</strong> Is there a way to return the results of a successful or failed <code>write.table</code> call? This is what I tried: </p>
  
  <pre><code>&gt; x &lt;- write.table(mydata, file="AllDat.csv", sep=",", row.names = FALSE, col.names=TRUE, append=FALSE
  
  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 'AllDat.csv': Permission denied
  
  &gt; x
  NULL
  </code></pre>
  
  <p>The variable x remains NULL even for a successful <code>write.table</code>. </p>