Q:

Determining age of a file in R

I'm trying to determine age of a file in R. Here is a link that I found:
Determining age of a file in shell script
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.
Update (I think this is working):
ageoffile <- 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)
}

A:

You can get the information about your file using the file.info() function, and the current date and time using Sys.time()
info <- file.info("PATH_TO_YOUR_FILE")
Sys.time() - info$mtime

For instance:
> system("touch temp")
> info <- file.info("temp")
> Sys.time() - info$mtime
Time difference of 5.23292 secs

