Open/Close Minute Price Data. Next Minute open is always equal to previous minute close. Exemplary data set:
dt open close
1998-01-02 09:30:00 100 101
1998-01-02 09:31:00 101 102
...
1998-01-02 15:59:00 105 106
After the last row I want to add another row like this:
dt open close
1998-01-02 09:30:00 100 101
1998-01-02 09:31:00 101 102
...
1998-01-02 15:59:00 105 106
1998-01-02 16:00:00 106 NA
That is, the timestamp is increased by one minute, open is equal to previous minute close and close is NA. My naive approach does not work:
library(lubridate)
library(dplyr)
data <- add_row(data, dt = max("dt") + minute(1), open = close[[n()]])
Any ideas?