receptor | year | month | day | hour | hour.inc | lat | lon | height | pressure | date |
---|---|---|---|---|---|---|---|---|---|---|
1 | 2018 | 1 | 3 | 19 | 0 | 31.768 | -106.501 | 500.0 | 835.6 | 2018-01-03 19:00:00 |
1 | 2018 | 1 | 3 | 18 | -1 | 31.628 | -106.350 | 508.8 | 840.5 | 2018-01-03 18:00:00 |
1 | 2018 | 1 | 3 | 17 | -2 | 31.489 | -106.180 | 526.2 | 839.4 | 2018-01-03 17:00:00 |
1 | 2018 | 1 | 3 | 16 | -3 | 31.372 | -105.974 | 547.6 | 836.8 | 2018-01-03 16:00:00 |
1 | 2018 | 1 | 3 | 15 | -4 | 31.289 | -105.731 | 555.3 | 829.8 | 2018-01-03 15:00:00 |
1 | 2018 | 1 | 3 | 14 | -5 | 31.265 | -105.462 | 577.8 | 812.8 | 2018-01-03 14:00:00 |
1 | 2018 | 1 | 3 | 13 | -6 | 31.337 | -105.175 | 640.0 | 793.9 | 2018-01-03 13:00:00 |
1 | 2018 | 1 | 3 | 12 | -7 | 31.492 | -104.897 | 645.6 | 809.2 | 2018-01-03 12:00:00 |
1 | 2018 | 1 | 3 | 11 | -8 | 31.671 | -104.700 | 686.8 | 801.0 | 2018-01-03 11:00:00 |
1 | 2018 | 1 | 3 | 10 | -9 | 31.913 | -104.552 | 794.2 | 795.8 | 2018-01-03 10:00:00 |
2 | 2018 | 1 | 4 | 19 | 0 | 31.768 | -106.501 | 500.0 | 830.9 | 2018-01-04 19:00:00 |
2 | 2018 | 1 | 4 | 18 | -1 | 31.904 | -106.635 | 611.5 | 819.5 | 2018-01-04 18:00:00 |
2 | 2018 | 1 | 4 | 17 | -2 | 32.070 | -106.749 | 709.7 | 808.0 | 2018-01-04 17:00:00 |
2 | 2018 | 1 | 4 | 16 | -3 | 32.223 | -106.855 | 787.3 | 794.9 | 2018-01-04 16:00:00 |
Above is what my dataframe looks like but I am trying to create a new column called date1 and will look like the frame below.
receptor year month day hour hour.inc lat lon height pressure date date1
1 1 2018 1 3 19 0 31.768 -106.501 500.0 835.6 2018-01-03 19:00:00 2018-01-03 19:00:00
2 1 2018 1 3 18 -1 31.628 -106.350 508.8 840.5 2018-01-03 18:00:00 2018-01-03 19:00:00
3 1 2018 1 3 17 -2 31.489 -106.180 526.2 839.4 2018-01-03 17:00:00 2018-01-03 19:00:00
4 1 2018 1 3 16 -3 31.372 -105.974 547.6 836.8 2018-01-03 16:00:00 2018-01-03 19:00:00
5 1 2018 1 3 15 -4 31.289 -105.731 555.3 829.8 2018-01-03 15:00:00 2018-01-03 19:00:00
6 1 2018 1 3 14 -5 31.265 -105.462 577.8 812.8 2018-01-03 14:00:00 2018-01-03 19:00:00
7 1 2018 1 3 13 -6 31.337 -105.175 640.0 793.9 2018-01-03 13:00:00 2018-01-03 19:00:00
8 1 2018 1 3 12 -7 31.492 -104.897 645.6 809.2 2018-01-03 12:00:00 2018-01-03 19:00:00
9 1 2018 1 3 11 -8 31.671 -104.700 686.8 801.0 2018-01-03 11:00:00 2018-01-03 19:00:00
10 1 2018 1 3 10 -9 31.913 -104.552 794.2 795.8 2018-01-03 10:00:00 2018-01-03 19:00:00
38 2 2018 1 4 19 0 31.768 -106.501 500.0 830.9 2018-01-04 19:00:00 2018-01-04 19:00:00
39 2 2018 1 4 18 -1 31.904 -106.635 611.5 819.5 2018-01-04 18:00:00 2018-01-04 19:00:00
40 2 2018 1 4 17 -2 32.070 -106.749 709.7 808.0 2018-01-04 17:00:00 2018-01-04 19:00:00
41 2 2018 1 4 16 -3 32.223 -106.855 787.3 794.9 2018-01-04 16:00:00 2018-01-04 19:00:00
Disregard the index furthest to the left. I want to match the receptor (Ex:1,2) with the first occurrence of the date (Ex: 2018-01-03 19:00:00,2018-01-04 19:00:00) and then repeat till the receptor changes.
I'm working in R so I'd like to find a solution in R but I could also use a python solution and make use of the Reticulate package in R.