Nikos Skalis Nikos Skalis - 25 days ago 5
R Question

how-to convert a list of unix-time values to a time series class object

If I have a vector of unix timestamps, for example

> head(debug$time)
[1] 1.473639e+18 1.473639e+18 1.473639e+18 1.473639e+18 1.473640e+18
[6] 1.473640e+18

How can I use it as a
vector in order to form a
object ?
I need this in order to parameterise and use the bfast library docs

I tired to do the following (tz=CEST is not recognised btw):

t_ <- as.POSIXct(as.numeric(debug$time), origin = '1970-01-01')

Could you please advise on this one ?


Use this for a way around the CEST problem, but all you need to do is:

vals <- c(1.473639e+18, 1.473639e+18, 1.473639e+18, 1.473639e+18, 1.473640e+18, 1.473640e+18)
as.POSIXct(vals/1000000000, origin="1970-01-01 00:00:00")
## [1] "2016-09-11 20:10:00 EDT" "2016-09-11 20:10:00 EDT" "2016-09-11 20:10:00 EDT" "2016-09-11 20:10:00 EDT" "2016-09-11 20:26:40 EDT"
## [6] "2016-09-11 20:26:40 EDT"

To make the date/time conversion work.