Convert Time Series to Intervals

Share:

Description

Function to convert a continuous time series data to interval data. The last row which goes to infinity can be deleted, else will be given dump value.

Usage

1
2
convert_ts_to_interval(df, endtime_lastrow = as.POSIXct(NA),
  arrange_cols = T, time_colname = "timestamp", round_duration = 2)

Arguments

df

A data frame with continuous time series data

endtime_lastrow

POSIXct value for the last row. Defaults to NA

arrange_cols

Whether to add the interval and duration columns at the front or not

time_colname

Column name of the timestamp variable

round_duration

Number of decimals to rounds the duration to. Defaults to 2. If no rounding required, give NULL.

See Also

convert_interval_to_ts

Examples

1
2
3
ts_data = data.frame(ts = as.POSIXct(c(0.5, 1, 1.008, 1.011),  tz = 'UTC', origin = "1970-01-01"),
                     x = c("a", "b", "c", "d"), y = c("e", "e", "e", "f"))
convert_ts_to_interval(ts_data, time_colname = "ts", endtime_lastrow = ts_data$ts[1] + 10)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.