Skip to content
Prev 322806 / 398503 Next

Chron format question h:m not working

On Wed, May 1, 2013 at 12:28 PM, Stephen Sefick <sas0025 at auburn.edu> wrote:
1. Note that as.chron works so this converts it to a chron date/time
using today as the date part and then subtracts off the date part:

ch <- as.chron("15:00", "%H:%M")
ch - c(dates(ch))

An alternative to the last line that also works is:

times(as.numeric(ch) %% 1)

2. Here is yet another approach.  Since 1970-01-01 is internally
represented by chron as 0:

times(as.chron(paste0("1970-01-01 ", "15:00", ":00")))

3. and another which is a mix of the above two:

times(as.chron(paste(chron(0), "15:00"), "%m/%d/%y %H:%S"))




--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com