title: Determining age of a file in R
body: <p>I'm trying to determine age of a file in R. Here is a link that I found:
  <a href="https://stackoverflow.com/questions/969407/determining-age-of-a-file-in-shell-script">Determining age of a file in shell script</a></p>
  
  <p>I'm wondering is there any native R way to determine the age of a file in days unit(or hours). 
  Thank you for reading this.</p>
  
  <p>Update (I think this is working):</p>
  
  <pre><code>ageoffile &lt;- function(x,unit="sec"){
    dt = .Internal(Sys.time())-.Internal(file.info(x))$mtime
    if(unit=="hours")
      return(dt/3600)
    else if(unit=="days")
      return(dt/(3600*24))
    else return(dt)
  }
  </code></pre>