R Question

convert data to timeseries in R

How to convert following data to timeseries in R:

time value
0 1
0.25 2
0.5 5
0.75 8

Answer

This should do it:

foo <- data.frame(time = c(0, 0.25, 0.5, 0.75), value = c(1, 2, 5, 8))
foo_ts <- as.ts(foo, start = 0, end = 0.75)