I have a data frame with 3 columns. (https://pastebin.com/DFqUuuDp)
The first two columns ("Time1","Time2") contain datetime data and have both the posixct format: "%Y-%m-%d %H:%M:%S".
So what i need ultimately is a subselect of rows, where for a particular time in Time1, only the rows are selected where Time2
- is one day before Time1 (here one day is not always 24 hours; one day means the calendar day before. basically "yesterday")
- and Time2 is < 12:00 Am.
A correct example:
+---------------------+----------------------+
| Time1 | Time2 |
+---------------------+----------------------+
| 2016-11-01 00:00:00 | 2016-10-31 00:00:00 |
+---------------------+----------------------+
A wrong example:
+---------------------+----------------------+
| Time1 | Time2 |
+---------------------+----------------------+
| 2016-11-01 00:00:00 | 2016-10-31 12:00:00 |
+---------------------+----------------------+
In the uploaded file, I added manually the third column ("Value") as a guidance for rows which i want to have filtered at the end. The rows with a "True" are interesting me.
I solved it with two for loops, but it is very slow going through large tables.
dput(head(df,20))? It will be easier for everyone. - MKRlubridate. Have a look, - MKR