[R] Adding duration (hh:mm:ss)\Converting factor column into duration class

drr daniel.roj at wp.pl
Thu Mar 29 13:57:46 CEST 2012


Hi All,

I have a data frame:

              Time1    Time2
     1  176:46:10    41:48:06
     2  171:28:57    61:19:10
     3  178:25:15    34:05:35 
     4   74:04:20     25:01:55
     5  136:11:20    37:59:32
     6  138:17:17    30:22:27
     7  183:04:48    29:25:02
     8  179:35:01    19:29:44

> str(df)
'data.frame':   8 obs. of  2 variables:
 $ Time1: Factor w/ 583 levels "","00:00:01",..: 574 573 575 583 565 566 579
577
 $ Time2: Factor w/ 1298 levels "00:00:00","00:00:01",..: 1292 1297 1288
1281 1290 1286 1284 1279

I would like to make calculations (adding, summing) on this data. How do I
transform those factors into duration data (in format hh:mm:ss).  I have
already found *lubridate* package but it does not work with factors. I tried
to convert as numeric, but it never works for me.
 
How do I do that?

--
View this message in context: http://r.789695.n4.nabble.com/Adding-duration-hh-mm-ss-Converting-factor-column-into-duration-class-tp4515210p4515210.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list