[R] Determining which file is newer

2009-10-23 Thread Dennis Fisher

Colleagues,

I wish to execute a task only if a particular file is newer than a  
second file.  I can access the file modification dates using  
file.info()$mtime.

This yields a time object (? POSIX).
sizeisdir   modemtime   
ctime
Testfile4421FALSE   755 2009-10-23 08:59:09 
2009-10-23 08:59:09
What is the simplest means to compare these two objects?

R2.9.1 in OSX, Windows, Linux

Dennis

Dennis Fisher MD
P  (The P Less Than Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Determining which file is newer

2009-10-23 Thread Henrik Bengtsson
Have a look at your company name and your phone number.  Nudge nudge,
wink wink, say no more... /H

On Fri, Oct 23, 2009 at 9:02 AM, Dennis Fisher fis...@plessthan.com wrote:
 Colleagues,

 I wish to execute a task only if a particular file is newer than a second
 file.  I can access the file modification dates using file.info()$mtime.
 This yields a time object (? POSIX).
                        size    isdir   mode    mtime
           ctime
        Testfile        4421    FALSE   755     2009-10-23 08:59:09
   2009-10-23 08:59:09
 What is the simplest means to compare these two objects?

 R2.9.1 in OSX, Windows, Linux

 Dennis

 Dennis Fisher MD
 P  (The P Less Than Company)
 Phone: 1-866-PLessThan (1-866-753-7784)
 Fax: 1-866-PLessThan (1-866-753-7784)
 www.PLessThan.com

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Determining which file is newer

2009-10-23 Thread Barry Rowlingson
On Fri, Oct 23, 2009 at 5:02 PM, Dennis Fisher fis...@plessthan.com wrote:
 Colleagues,

 I wish to execute a task only if a particular file is newer than a second
 file.  I can access the file modification dates using file.info()$mtime.
 This yields a time object (? POSIX).
                        size    isdir   mode    mtime
           ctime
        Testfile        4421    FALSE   755     2009-10-23 08:59:09
   2009-10-23 08:59:09
 What is the simplest means to compare these two objects?

 Split the string representation of the object into date and time
parts, then split those parts into day, month , year and hour minute
second, taking care of internationalisation and localisation, then
recombine all those parts into a number of seconds since Jan 1 1970,
taking care of leap seconds and the slowing down of the earth due to
the tides of the moon.

 Or just use the usual operators:

  file.info(/etc/passwd)$mtime = file.info(/etc/motd)$mtime
[1] TRUE

Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.