title: How to check if a filename is writeable in R?
body: <p>How can I check if a specific filename can be written to?  Ideally I would like a function that works in the same way as file.exists() - it returns TRUE or FALSE, and doesn't spit out any errors whilst testing.</p>
  
  <p>The ideal example:</p>
  
  <pre><code>filename = "X:/an/invalid/path"
  file.writable(filename) # returns FALSE
  </code></pre>
  
  <p>I have not found a function that already does this, and can't really think about how to go about it.</p>
  
  <p>One idea would be to try writing some junk data to <code>filename</code>, but I can't figure out the intricacies of using <code>try()</code> or <code>tryCatch()</code> to avoid lots of error messages coming out.  That also has the downside of overwriting the filename, which you might not want to happen.</p>