Q:

how to convert seconds to a date in R

I have a column with seconds. The start date is 09/01/2017 01:37:33.
I would like to replace the seconds with the date based on the calculations (taking into account the start date). But I couldn't find any answer to this question... Can someone help me, please?

A:

Convert to POSIXct and add the number of seconds.  seconds can be a vector of seconds.
seconds <- 2
as.POSIXct("09/01/2017 01:37:33", format = "%m/%d/%Y %H:%M:%S") + seconds
## [1] "2017-09-01 01:37:35 EDT"

