I have this database:
id x y z
<int> <chr> <dbl> <date>
1 A 1 NA
2 C 3 NA
3 C 3 NA
4 C 2 NA
5 B 2 2019-08-04
6 C 1 2019-09-18
7 B 3 2019-12-17
8 A 2 2019-11-02
9 A 3 2020-03-16
10 A 1 2020-01-31
And this data frame:
id date
<dbl> <date>
1 2012-09-25
1 2012-03-26
1 2012-11-12
2 2013-01-24
2 2012-05-04
2 2012-02-24
3 2012-05-30
3 2012-02-15
4 2012-03-13
4 2012-05-18
I need to fill the NA values of the z column with the oldest dates of the data.frame ids. How can it be done? My desired result is this:
id x y z
<int> <chr> <dbl> <date>
1 A 1 2012-03-26
2 C 3 2012-02-24
3 C 3 2012-02-15
4 C 2 2012-03-13
5 B 2 2019-08-04
6 C 1 2019-09-18
7 B 3 2019-12-17
8 A 2 2019-11-02
9 A 3 2020-03-16
10 A 1 2020-01-31