1
Hello! I’m trying to find in the database (agua
and meteo
) the day of the month of agua
in common with the meteo
and when to find the meteo
finds the same day (for the Alqueva-Montante station), make in it the average of the 15 days prior to the common day.
> 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
Tell you what, it’s not working out for me.
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 )
dput(head(agua, 30))
anddput(head(meteo, 30))
would help (since we will need to do 15-day mobile media). 2) What isd
? 3) What exactly doesn’t work?– Tomás Barcellos
d
is a variable that contains the "Alqueva-Montante" station and averages the previous 15 days of theDia
ofmeteo
– Maria Lopes
But her definition is not in the question code. Include this and also the
dput(...)
requested.– Tomás Barcellos