Hello! I'm trying to find in the database ( agua
and meteo
) the day of the month of agua
in common with meteo
and when I find meteo
it finds the same day (for Alqueva-Amante station) , make it the average of the 15 days before the day in common.
> head(agua)
Ano Mes Dia Estacao Secchi OD Turb Temp Ts_Tf SST Clorofila_a
1 2002 1 NA Alqueva-Montante NA NA NA NA NA NA NA
2 2002 1 NA Alqueva-Mourão NA NA NA NA NA NA NA
3 2002 2 14 Alqueva-Montante NA 22.03 NA NA NA 18 186.0
4 2002 2 21 Alqueva-Montante NA 11.39 NA NA NA 12 31.5
> head(meteo)
Ano Mes Dia Estacao DirVento HumidadeRelativa Precipitacao Pressao Radiacao
1 2002 7 19 Alqueva-Montante 347.4361 39.27273 NA 999.7417 373.3333
2 2002 7 20 Alqueva-Montante 339.2638 57.91667 NA 1003.0917 215.7917
3 2002 7 21 Alqueva-Montante 337.9830 59.54167 NA 1003.7792 308.0833
4 2002 7 22 Alqueva-Montante 343.3900 68.58333 NA 1007.1625 169.2917
5 2002 7 23 Alqueva-Montante 324.4686 57.04167 NA 1008.2417
I did the following, it's not working.
library(dplyr)
d %>%
group_by(meteo$Estacao=='Alqueva-Montante') %>%
summarise_at(meteo$Dia[-15], mean, na.rm)
a <- ifelse(meteo$Dia=agua$Dia, d, agua$Dia )