[R] Convert Time Variable to Numeric

Don MacQueen macq at llnl.gov
Tue Nov 24 20:35:57 CET 2009


Perhaps something like:

>  as.numeric(chron(times.=c('01:23:21','11:12:13')))
[1] 0.05788194 0.46681713

-Don

At 7:02 AM -0800 11/24/09, RanjanV wrote:
>Hello Everyone
>
>I am new to R
>
>I would like to know how to deal with Time Variable. If I have a column of
>containing Time data in the format of hh:mm:ss such as 00:56:45, 01:24:36,
>01:41:25, and so on......
>
>I could find averages for this column using the Chron package. But now I
>need to plot a graph so I need to convert this Time variable to numeric.
>
>My data is as follows:
>Activity               Time Required
>A                        00:56:45
>B                        01:24:36
>C                        01:41:25
>D                        01:48:25
>E                        01:51:25
>F                        01:55:25
>G                        01:59:25
>and so on..............
>
>total rows in my data are 150
>Can someone guide me regarding converting this Time variable to numeric?
>
>Thank you
>RanjanV
>--
>View this message in context: 
>http://*old.nabble.com/Convert-Time-Variable-to-Numeric-tp26497413p26497413.html
>Sent from the R help mailing list archive at Nabble.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.


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




More information about the R-help mailing list