what package should I include to use timeDate? I want to convert a double (num of millis) into date object.
library("chron") Joao ----- Original Message ----- From: "Yasser El-Zein" <abu3ammar at gmail.com> To: <r-help at stat.math.ethz.ch> Sent: Monday, November 22, 2004 5:45 PM Subject: [R] timeDate> what package should I include to use timeDate? I want to convert a > double (num of millis) into date object. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
Yasser El-Zein <abu3ammar <at> gmail.com> writes: : : what package should I include to use timeDate? I want to convert a : double (num of millis) into date object. The times class of the chron package stores times as fractions of a day. You could check whether or not that gives you the resolution you need. Install chron and issue the R commands: library(chron) ?chron If you only need resolution to the second then you could alternately use the POSIXct class. Also check out the article on dates and times in R News 4/1 which discusses the various possibilities.
Yasser El-Zein wrote:> what package should I include to use timeDate? I want to convert a > double (num of millis) into date object. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlYou might want to read the Help Desk column in R News 4 (1). Uwe Ligges
>From the document it is apparent to me that I need as.POSIXct (I havea double representing the number of millis since 1/1/1970 and I need to construct a datetime object). I see it showing how to construct the time object from a string representing the time but now fro a double of millis. Does anyone know hoe to do that? On Mon, 22 Nov 2004 19:24:48 +0100, Uwe Ligges <ligges at statistik.uni-dortmund.de> wrote:> Yasser El-Zein wrote: > > > > > what package should I include to use timeDate? I want to convert a > > double (num of millis) into date object. > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > You might want to read the Help Desk column in R News 4 (1). > > Uwe Ligges > >
Yasser El-Zein <abu3ammar <at> gmail.com> writes:> > >From the document it is apparent to me that I need as.POSIXct (I have > a double representing the number of millis since 1/1/1970 and I need > to construct a datetime object). I see it showing how to construct the > time object from a string representing the time but now fro a double > of millis. Does anyone know hoe to do that? >If by millis you mean milliseconds (i.e. one thousandths of a second) then POSIXct does not support that resolution, but if rounding to seconds is ok then structure(round(x/1000), class = c("POSIXt", "POSIXct")) should give it to you assuming x is the number of milliseconds.
I am looking for up to the millisecond resolution. Is there a package that has that? On Mon, 22 Nov 2004 21:48:20 +0000 (UTC), Gabor Grothendieck <ggrothendieck at myway.com> wrote:> Yasser El-Zein <abu3ammar <at> gmail.com> writes: > > > > > >From the document it is apparent to me that I need as.POSIXct (I have > > a double representing the number of millis since 1/1/1970 and I need > > to construct a datetime object). I see it showing how to construct the > > time object from a string representing the time but now fro a double > > of millis. Does anyone know hoe to do that? > > > > If by millis you mean milliseconds (i.e. one thousandths of a second) > then POSIXct does not support that resolution, but if rounding to > seconds is ok then > > structure(round(x/1000), class = c("POSIXt", "POSIXct")) > > should give it to you assuming x is the number of milliseconds. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
You might want to check out 'chron'. This stores the time as days and fractions of a day. If you take the current date,> as.numeric(chron(dates.="11/23/2004"))[1] 12745>you get the value above. If you change this to millisecond, you get> as.numeric(chron(dates.="11/23/2004")) * 86400 * 1000[1] 1.101168e+12>this value requires 46 bits and since a floating point number has 54 bits of value, it should be enough to give you millisecond resolution and still maintain the 'date' __________________________________________________________ James Holtman "What is the problem you are trying to solve?" Executive Technical Consultant -- Office of Technology, Convergys james.holtman at convergys.com +1 (513) 723-2929 Yasser El-Zein <abu3ammar at gmail.com> To: r-help at stat.math.ethz.ch Sent by: cc: r-help-bounces at stat.m Subject: Re: [R] timeDate ath.ethz.ch 11/23/2004 09:55 Please respond to Yasser El-Zein I am looking for up to the millisecond resolution. Is there a package that has that? On Mon, 22 Nov 2004 21:48:20 +0000 (UTC), Gabor Grothendieck <ggrothendieck at myway.com> wrote:> Yasser El-Zein <abu3ammar <at> gmail.com> writes: > > > > > >From the document it is apparent to me that I need as.POSIXct (I have > > a double representing the number of millis since 1/1/1970 and I need > > to construct a datetime object). I see it showing how to construct the > > time object from a string representing the time but now fro a double > > of millis. Does anyone know hoe to do that? > > > > If by millis you mean milliseconds (i.e. one thousandths of a second) > then POSIXct does not support that resolution, but if rounding to > seconds is ok then > > structure(round(x/1000), class = c("POSIXt", "POSIXct")) > > should give it to you assuming x is the number of milliseconds. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide!http://www.R-project.org/posting-guide.html>______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html