
Last chance! 50% off unlimited learning
Sale ends in
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.
convert_ts_to_interval(df, endtime_lastrow = as.POSIXct(NA),
arrange_cols = T, time_colname = "timestamp", round_duration = 6)
A data frame with continuous time series data
POSIXct value for the last row. Defaults to NA
Whether to add the interval and duration columns at the front or not
Column name of the timestamp variable
Number of decimals to rounds the duration to. Defaults to 2. If no rounding required, give NULL.
# NOT RUN {
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)
# }
Run the code above in your browser using DataLab