Dear R People: I am looking at the ctime attribute of two different files. It contains the year, month, day, time of creation and time zone. Is there a way to determine the difference between the ctimes of two files, please? I looked in the chron package and nothing seemed to work. Thanks in advance, Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodgess at gmail.com
Try this:> file.info("abc.R")$ctime - file.info("aa.R")$ctimeTime difference of 228.9912 days On Wed, Jul 22, 2009 at 10:44 AM, Erin Hodgess<erinm.hodgess at gmail.com> wrote:> Dear R People: > > I am looking at the ctime attribute of two different files. ?It > contains the year, month, day, time of creation and time zone. > > Is there a way to determine the difference between the ctimes of two > files, please? > > I looked in the chron package and nothing seemed to work. > > Thanks in advance, > Sincerely, > Erin > > > -- > Erin Hodgess > Associate Professor > Department of Computer and Mathematical Sciences > University of Houston - Downtown > mailto: erinm.hodgess at gmail.com > > ______________________________________________ > R-help at 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. >
On Wednesday, July 22, 2009 10:44 AM, Erin Hodgess wrote: > ...I am looking at the ctime attribute of > two different files. It contains the year, > month, day, time of creation and time zone. > Is there a way to determine the difference > between the ctimes of two files, please... are you looking for something different from > file1 <- file.info ( '~/Desktop/file1.txt' ) $ ctime > file1 [1] "2009-07-20 16:35:17 EDT" > file2 <- file.info ( '~/Desktop/file2.txt' ) $ ctime > file2 [1] "2009-02-12 18:58:47 EST" > file1 - file2 Time difference of 157.8587 days > David -- David ? ----------------------------------------------------- David Huffer, Ph.D. Senior Statistician CSOSA/Washington, DC david.huffer at csosa.gov
On 22 July 2009 at 09:44, Erin Hodgess wrote: | I am looking at the ctime attribute of two different files. It | contains the year, month, day, time of creation and time zone. [ Well only if you convert it to POSIXlt... ] | Is there a way to determine the difference between the ctimes of two | files, please? Just use '-' or the difftime() functions. As help(file.info) clearly states, the class of the ctime component is a standard POSIXct and your problem reduces to the common difference between two POSIXct times. Which R happens to excel at:> bashrc <- file.info("~/.bashrc")$ctime > Rprofile <- file.info("~/.Rprofile")$ctime > Rprofile - bashrcTime difference of 52.57426 days> difftime(Rprofile, bashrc, units="weeks")Time difference of 7.510608 weeks See ?difftime for other units, and use as.numeric() to cast to just a number. Hth, Dirk -- Three out of two people have difficulties with fractions.