If I have a dataframe A
A =
year month day hour minute rain
.
.
.
2000 01 01 01 00 2
2000 01 01 01 15 2
2000 01 01 01 30 NA
2000 01 01 01 45 3
2000 01 01 02 00 4
2000 01 01 02 15 5
.
.
.
Dataframe A have data from 1990 to 2000 with a frequency data of 15 minutes.
so A have the same dates and different years of specific missing data (NA):
A =
year month day hour minute rain
1990 01 01 01 30 10
.
.
.
1991 01 01 01 30 21
.
.
.
1992 01 01 01 30 4
.
.
.
1993 01 01 01 30 6
.
.
.
1994 01 01 01 30 10
.
.
.
1995 01 01 01 30 23
.
.
.
1996 01 01 01 30 0
.
.
.
1997 01 01 01 30 0
.
.
.
1998 01 01 01 30 0
.
.
.
1999 01 01 01 30 6
.
.
.
2000 01 01 01 30 NA
The idea is to look for every NA data in Rain column and replace them with the average of the same date of each year from 1990 to 2000.
The new A would be for 2000 year:
A =
year month day hour minute rain
.
.
.
2000 01 01 01 00 2
2000 01 01 01 15 2
2000 01 01 01 30 **8**
2000 01 01 01 45 3
2000 01 01 02 00 4
2000 01 01 02 15 5
.
.
.