Extracting time from POSIXct

后端 未结 6 720
梦如初夏
梦如初夏 2020-11-28 23:02

How would I extract the time from a series of POSIXct objects discarding the date part?

For instance, I have:

times <- structure(c(1331086009.5009         


        
6条回答
  •  生来不讨喜
    2020-11-28 23:28

    I can't find anything that deals with clock times exactly, so I'd just use some functions from package:lubridate and work with seconds-since-midnight:

    require(lubridate)
    clockS = function(t){hour(t)*3600+minute(t)*60+second(t)}
    plot(clockS(times),val)
    

    You might then want to look at some of the axis code to figure out how to label axes nicely.

提交回复
热议问题