On Tue, Aug 12, 2014 at 2:40 PM, John McKown <john.archie.mck...@gmail.com> wrote: <snip> > You can simply make that a function > > getTimePortion <- function(POSIXct_value) { > value_in_seconds=as.integer(POSIXct_value); > sprintf("%02d:%02d:%02d", # C-style > formatting string > seconds_vector/3600, # hour value > (seconds_vector%%3600)/60, #minute value > seconds_vector%%60); #second value > }; >
Sorry, cut'n'pasted that incorrectly getTimePortion <- function(POSIXct_value) { value_in_seconds=as.integer(POSIXct_value); sprintf("%02d:%02d:%02d", # C-style value_in_seconds/3600, # hour value (value_in_seconds%%3600)/60, #minute value value_in_seconds_vector%%60); #second value }; And the above is "vectorized" and will work if argument has multiple values in it. -- There is nothing more pleasant than traveling and meeting new people! Genghis Khan Maranatha! <>< John McKown ______________________________________________ R-help@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.