Here is a reproducible example-
data <- rnorm(6)
dates1 <- as.POSIXct("2019-03-18 10:30:00", tz = "CET") + 0:2*60
dates2 <- as.POSIXct("2019-03-19 08:30:00", tz = "CET") + 0:2*60
dates <- append(dates1, dates2)
R <- xts(x = data, order.by = dates)
colnames(R) <- "R"
R$Label[1:6] <- 1
R$Label[4:6] <- 2
Output:
2019-03-18 10:30:00 0.8303556 1
2019-03-18 10:31:00 -1.5585603 1
2019-03-18 10:32:00 -0.1266884 1
2019-03-19 08:30:00 0.3562468 2
2019-03-19 08:31:00 1.0219780 2
2019-03-19 08:32:00 2.5127290 2
I am trying to create dataframe where the expected result is as following:
Label| start timestamp |end timestamp | start R | end R
1 | 2019-03-18 10:30:00|2019-03-18 10:32:00| 0.8303556|-0.1266884
.
.
Can you kindly help? I can separately call these values but unfortunately not being able to put them altogether.