[R] timeDate

Don MacQueen macq at llnl.gov
Mon Nov 22 23:33:42 CET 2004


In which case, be aware that R's round() function rounds to the 
nearest even number when the fraction is 0.5:

>  round(c(1.5,2.5))
[1] 2 2

which might not be desirable for times. Consider floor() or trunc() instead.

>  floor(c(1.5,2.5))
[1] 1 2
>  trunc(c(1.5,2.5))
[1] 1 2


At 9:48 PM +0000 11/22/04, Gabor Grothendieck 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


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA




More information about the R-help mailing list