See: ?DateTimeClasses ?as.POSIXct ?strptime ?difftime The example for difftime should help: (z <- Sys.time() - 3600) Sys.time() - z # just over 3600 seconds. ## time interval between releases of 1.2.2 and 1.2.3. ISOdate(2001, 4, 26) - ISOdate(2001, 2, 26) as.difftime(c("0:3:20", "11:23:15")) as.difftime(c("3:20", "23:15", "2:"), format= "%H:%M")# 3rd gives NA HTH, Andy
See: ?DateTimeClasses ?as.POSIXct ?strptime ?difftime The example for difftime should help: (z <- Sys.time() - 3600) Sys.time() - z # just over 3600 seconds. ## time interval between releases of 1.2.2 and 1.2.3. ISOdate(2001, 4, 26) - ISOdate(2001, 2, 26) as.difftime(c("0:3:20", "11:23:15")) as.difftime(c("3:20", "23:15", "2:"), format= "%H:%M")# 3rd gives NA HTH, Andy
I am a beginner in R with a background in SAS. Are there built-in R methods of reading dates for calculating elapsed days between two calendar dates? If so, are there any examples I can browse? Thanks in anticipation. John Byrne. Lecturer in Information Systems. Australian Catholic University.
Hi John. I'm a beginner in SAS with a background in R ;-) Browse the HTML Help "help.start()" and search for keywords Date or time. You will find several function managing this task. You can do Your MDY that You know from SAS but the R functions are a bit superior and more flexible to those given by SAS...> > > > >I am a beginner in R with a background in SAS. > >Are there built-in R methods of reading dates for calculating elapsed days >between two calendar dates? If so, are there any examples I can browse? > >Thanks in anticipation. > >John Byrne. >Lecturer in Information Systems. >Australian Catholic University. > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help >-- Trebate bolji pristup internetu? Nazovite IskonInternet na 0800 1000 ili pogledajte http://www.iskon.biz/individualni/usluge/dialup/
There are two datetime systems available. 1. The POSIXt system in the R base, encompassing the POSIXlt and POSIXct classes. Others have already described where to get info on these. 2. The Bell Labs chron package. Info available at: require(chron) ?chron You may also find this article on chron useful: http://cm.bell-labs.com/cm/ms/departments/sia/dj/papers/chron.pdf A key difference between the two, aside from the specific names and arguments of the functions involved, is that POSIXt works with timezones and with daylight savings time whereas chron does not. I personally use chron for all my stats problems in order to avoid introducing certain subtleties of timezones and daylight savings times. I use POSIXt when I need to manipulate time stamps of files from the operating system since POSIXt provides a close fit to how operating systems handle dates and time. Based on books and documentation for R I believe that most people use POSIXt. --- Date: Fri, 5 Dec 2003 10:40:29 +1100 From: john byrne <j.byrne at mackillop.acu.edu.au> To: <r-help at stat.math.ethz.ch> Subject: [R] Processing calendar dates with R I am a beginner in R with a background in SAS. Are there built-in R methods of reading dates for calculating elapsed days between two calendar dates? If so, are there any examples I can browse? Thanks in anticipation. John Byrne. Lecturer in Information Systems. Australian Catholic University. ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Hi! Don't konw much, but I worked with package "chron", function "dates": d2<-"2002-01-21" d1<-"2001-01-01" dates(d2, format="y-m-d") -dates(d1, format="y-m-d") # gives: # Time in days: # [1] 385 Actually I used something like dates(as.character(d2), format="y-m-d") cause the variable was read form a table as factor. Good luck! Karl