Working with time in R -


i struggling working time in r , wondered whether help.

for sample data frame:

df <- structure(list(time = structure(1:9, .label = c("07:55:40", "07:55:50",                                                        "07:56:00", "07:56:10", "07:56:20", "07:56:30", "07:56:40", "07:56:50",                                                        "07:57:00"), class = "factor")), .names = "time", class = "data.frame", row.names = c(na,                                                                                                                                              -9l)) 

i using following code lines convert time format r recognises (start.time) , adding 10 seconds start.time end.time.

df$start.time <- strptime(df$time, "%h:%m:%s")  ##correct df$end.time <- df$start.time + 10 

r automatically adds todays date both start , end.time not wanted - whilst understand r prefer have reference date well, purposes, not needed.

how exclude date?

try "times" class in chron. represents times in fractions of day 1 second 1 / (24 * 60 * 60). note times must less 24:00:00 :

> library(chron) > transform(df, time = times(time) + 10 / (24 * 60 * 60))       time 1 07:55:50 2 07:56:00 3 07:56:10 4 07:56:20 5 07:56:30 6 07:56:40 7 07:56:50 8 07:57:00 9 07:57:10 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -