[R] How to convert time to days
Muhammad Subianto
subianto at gmail.com
Thu Oct 27 13:03:15 CEST 2005
Thanks to everyone for your help.
Yuup, this is my stupid word "secs" which I put there.
Usually I get to run simulation on my machine only a few seconds.
Now, I recode my timestamp, but still I don't know how to make
x days, x hours, x minutes, x seconds.
Best wishes, Muhammad Subianto
On this day 26/10/2005 10:00 PM, Don MacQueen wrote:
> The word "secs" appears in "Run time: 1.960625 secs" because you put
> it there in your cat() statement. It has nothing to do with the
> number itself.
>
> Simply try typing
>
> end.time - begin.time
>
> at the prompt, and see what you get.
>
> Then see
> ?difftime
> for more information. Example
> difftime(end.time,begin.time,units='hours')
>
> To get the interval formatted as "1 day, 23 hours, x minutes, x
> seconds" you will have to do more work.
>
> -Don
>
> At 4:18 PM +0200 10/26/05, Muhammad Subianto wrote:
>
>>Dear all,
>>I have ran a simulation in R.
>>This simulation was running about at least two days.
>>Here is below the result some part of my code about time result.
>>I don't understand about
>>
>>Start time: Mon Oct 24, 2005 at 04:23:01 PM
>> Finish time: Wed Oct 26, 2005 at 03:26:19 PM
>> Run time: 1.960625 secs.
>>
>>This is about two seconds or one day and nine hours?
>>Then, how could I convert to 1 day, 23 hours, ? minutes, ? seconds.
>>Thanks you very much for any suggestions.
>>
>>Best wishes, Muhammad Subianto
>>
>> >
>>################################################################################
>> > # Begin of program and timestamp:
>> > cat(format(begin.time <- Sys.time(), "%a %b %d %X %Y") ,"\n")
>>Mon Oct 24 04:23:01 PM 2005
>> > cat("Start time:", secs <- format(begin.time, "%X"), "\n")
>>Start time: 04:23:01 PM
>> > cat("Sys.time:", begin.time <- Sys.time(), '\n')
>>Sys.time: 1130163781
>> >
>> >
>>--- CODE SIMULATION ---
>> >
>> > # End of program and timestamp:
>> > cat("Sys.time:",end.time <- Sys.time(), '\n')
>>Sys.time: 1130333179
>> > cat("Run Time:",end.time-begin.time, 'secs.\n\n')
>>Run Time: 1.960625 secs.
>>
>> > cat("Finish time:", secs <- format(end.time, "%X"), "\n")
>>Finish time: 03:26:19 PM
>> > cat(format(end.time <- Sys.time(), "%a %b %d %X %Y") ,"\n")
>>Wed Oct 26 03:26:19 PM 2005
>> >
>> > cat("\n",
>>+ " Start time:", secs <- format(begin.time, "%a %b %d, %Y at
>>%X"), "\n",
>>+ "Finish time:", secs <- format(end.time, "%a %b %d, %Y at
>>%X"), "\n",
>>+ " Run time:", end.time-begin.time, 'secs.\n\n')
>>
>> Start time: Mon Oct 24, 2005 at 04:23:01 PM
>> Finish time: Wed Oct 26, 2005 at 03:26:19 PM
>> Run time: 1.960625 secs.
>>
>> >
>>###########################################################################
>>
>>______________________________________________
>>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
>
>
>
More information about the R-help
mailing list