We can use strptime
with format
format(strptime(sprintf("%04d", v1), "%H%M"), "%H:%M")
The above output is character
class, but if we needed a times
class, then we can use times
from chron
on a "HH:MM:SS" format created with sub
or from the above code
library(chron)
times(sub("(.{2})(.{2})","\1:\2:", sprintf("%04d00", v1)))
#[1] 12:15:00 14:23:00 15:44:00 11:00:00 06:45:00 13:24:00
Or
times(format(strptime(sprintf("%04d", v1), "%H%M"), "%H:%M:%S"))
data
v1 <- c( 1215,1423,1544,1100,0645,1324)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…