I am beginner in R so when I tried to make a for loop by sequence it gave me the expected result for one vector but for the second one, it gave me the same value along the vector (It made only the first iteration )
moyenne<- c()
ecart<-c()
for(i in seq(1,length(vector1), by=nbsim)){
moyenne<-c(moyenne, mean(P_totale-GRAVE- ATTRITIONNEL-vector2[i:i+nbsim-1]+vector1[i:i+nbsim-1]))
#mean of the result
ecart<-c(ecart,sqrt(var(vector1[i:i+nbsim-1]-vector2[i:i+nbsim-1]-ATTRITIONNEL-GRAVE+P_totale)))
#standard deviation of the result
}
moyenne
ecart
vector1 and vector 2 have the same length which is equal to 90000, P_totale, GRAVE and ATTRITIONNEL are vectors with length=nbsim My problem was with the vector "ecart", I didn't know why it gave me the same value, could someone help me, please ?