R 2.12.2 on Scientific Linux 6.4 #works chron(times.="15:00:00", format=c(times="h:m:s")) #doesn't work chron(times.="15:00", format=c(times="h:m")) From chron Manual: The times format can be any permutation of "h", "m", and "s" separated by any one non-special character. The default is "h:m:s". what am I missing? many thanks, -- Stephen Sefick ************************************************** Auburn University Biological Sciences 331 Funchess Hall Auburn, Alabama 36849 ************************************************** sas0025 at auburn.edu http://www.auburn.edu/~sas0025 ************************************************** Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis "A big computer, a complex algorithm and a long time does not equal science." -Robert Gentleman
A less-than-ancient version of R? The documentation does not say the dates. argument is optional. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. Stephen Sefick <sas0025 at auburn.edu> wrote:>R 2.12.2 on Scientific Linux 6.4 > >#works >chron(times.="15:00:00", format=c(times="h:m:s")) > >#doesn't work >chron(times.="15:00", format=c(times="h:m")) > > From chron Manual: >The times format can be any permutation of "h", "m", and "s" separated >by any one non-special character. The default is "h:m:s". > >what am I missing? > >many thanks,
HI, One possible way would be to use paste() chron(times.=paste0("15:00",":00"),format=c(times="h:m:s")) #[1] 15:00:00 #or you could use library(lubridate) hm("15:00") #[1] "15H 0M 0S" A.K. ----- Original Message ----- From: Stephen Sefick <sas0025 at auburn.edu> To: "r-help at r-project.org" <r-help at r-project.org> Cc: Sent: Wednesday, May 1, 2013 12:28 PM Subject: [R] Chron format question h:m not working R 2.12.2 on Scientific Linux 6.4 #works chron(times.="15:00:00", format=c(times="h:m:s")) #doesn't work chron(times.="15:00", format=c(times="h:m")) From chron Manual: The times format can be any permutation of "h", "m", and "s" separated by any one non-special character. The default is "h:m:s". what am I missing? many thanks, -- Stephen Sefick ************************************************** Auburn University Biological Sciences 331 Funchess Hall Auburn, Alabama 36849 ************************************************** sas0025 at auburn.edu http://www.auburn.edu/~sas0025 ************************************************** Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods.? We are mammals, and have not exhausted the annoying little problems of being mammals. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -K. Mullis "A big computer, a complex algorithm and a long time does not equal science." ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -Robert Gentleman ______________________________________________ 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.
On Wed, May 1, 2013 at 12:28 PM, Stephen Sefick <sas0025 at auburn.edu> wrote:> R 2.12.2 on Scientific Linux 6.4 > > #works > chron(times.="15:00:00", format=c(times="h:m:s")) > > #doesn't work > chron(times.="15:00", format=c(times="h:m")) > > From chron Manual: > The times format can be any permutation of "h", "m", and "s" separated by > any one non-special character. The default is "h:m:s". > > what am I missing? >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