Try this: Sys.setlocale(category = "LC_TIME", locale = "US") format(as.POSIXct('0001-01-01 00:00:00') + x, "%I:%M:%S %p")
On Mon, Apr 9, 2012 at 9:38 PM, cassie jones <cassiejone...@gmail.com> wrote: > > Hello everyone, > > I am wondering if there is any routine in R which can convert time given in > 'seconds' unit to the 12 hour time format. For example, suppose the data > set looks like > > x=c(36885,84000,20) #x in seconds > > I want to get the output as > > [1] " 11:14:45 AM" > [2] " 11:20:00 PM" > [3] "12:20:00 AM" > > Does anyone have any idea? Thanks in advance. > > > Cassie > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O ______________________________________________ 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.