title: R test if a file exists, and is not a directory
body: <p>I have an R script that takes a file as input, and I want a general way to know whether the input is a file that exists, and is not a directory. </p>
  
  <p>In Python you would do it this way: <a href="https://stackoverflow.com/questions/82831/how-do-i-check-whether-a-file-exists-using-python">How do I check whether a file exists using Python?</a>, but I was struggling to find anything similar in R.</p>
  
  <p>What I'd like is something like below, assuming that the <code>file.txt</code> actually exists:</p>
  
  <pre><code>input.good = "~/directory/file.txt"
  input.bad = "~/directory/"
  
  is.file(input.good) # should return TRUE
  is.file(input.bad) #should return FALSE
  </code></pre>
  
  <p>R has something called file.exists(), but this doesn't distinguish files from directories.</p>