Hi! I begin on Rstudio. I dispose of 20 years daily data of evapotranspiration. I would like to add the daily evapotranspiration values for each 10 days of each month, and thus have 3 values per month. That is:

1-10 ; 11-20 , 21-end of the month

Here is the loop I typed to perform this operation. It does not work but the code runs:

j=i*10
k=0
for (i in 2:nrow(data4)){
j=i*10

for (j in 11:nrow(data4)){

if ((data4$month[j]==data4$month[j-10]) && (k<3)){

k=k+1

for (l in (1:10)){

d<-sum(data4$etp)

}

}else{

k=0

}

}

}

Someone could help me please?