I tried to run the code and it worked previously. However, today I tried to run the same code, but it skips if and read it after all the for loop is done. Do you know the what the problem is?
So the code that occurs error is this. Z[i,0] is date. in the end of the for loop, I put print(i) and when I ran this code, all the i values are printed out. However after that, it gives me this error (Error in if (month(Z[i * 7 - 6, 0]) * 100 + day(Z[i * 7 - 6, 0]) < 801 || : missing value where TRUE/FALSE needed)
===
for(i in 1:2350){
if(month(Z[i*7-6,0])*100+day(Z[i*7-6,0])<801||(month(Z[i*7-6,0])*100+day(Z[i*7-6,0]))>=801+7){
if(month(Z[i*7-6+1,0])*100+day(Z[i*7-6+1,0])>=1226){
operation1<-paste0(" ",format(month(Z[i*7-6,0]),width=2)," ",format(day(Z[i*7-6,0]),width=2)," 10 1 5 2.00000 1.00 ",format(WellInput[k,2]*7,width=7)," 0.00 ",format(WellInput[k,3],width=8))
operation2<-paste0(" ",format(month(Z[i*7-6+1,0]),width=2)," ",format(day(Z[i*7-6+1,0]),width=2)," 10 2 5 0.00000 0.00 0.0000 0.00 0")
operation3<-" 17"
mgt<-c(mgt,operation1,operation2,operation3)
}else if(month(Z[i*7-6+1,0])*100+day(Z[i*7-6+1,0])==0101){
operation1<-paste0(" ",format(month(Z[i*7-6,0]),width=2)," ",format(day(Z[i*7-6,0]),width=2)," 10 1 5 2.00000 1.00 ",format(WellInput[k,2]*7,width=7)," 0.00 ",format(WellInput[k,3],width=8))
operation3<-" 17"
operation2<-paste0(" ",format(month(Z[i*7-6+1,0]),width=2)," ",format(day(Z[i*7-6+1,0]),width=2)," 10 2 5 0.00000 0.00 0.0000 0.00 0")
mgt<-c(mgt,operation1,operation3,operation2)
}else{
operation1<-paste0(" ",format(month(Z[i*7-6,0]),width=2)," ",format(day(Z[i*7-6,0]),width=2)," 10 1 5 2.00000 1.00 ",format(WellInput[k,2]*7,width=7)," 0.00 ",format(WellInput[k,3],width=8))
operation2<-paste0(" ",format(month(Z[i*7-6+1,0]),width=2)," ",format(day(Z[i*7-6+1,0]),width=2)," 10 2 5 0.00000 0.00 0.0000 0.00 0")
mgt<-c(mgt,operation1,operation2)
}
} else{
if(month(Z[i*7-6+1,0])*100+day(Z[i*7-6+1,0])==801){
operation4<-" 8 1 7 0 0.00001 0.99 "
operation1<-paste0(" ",format(month(Z[i*7-6,0]),width=2)," ",format(day(Z[i*7-6,0]),width=2)," 10 1 5 2.00000 1.00 ",format(WellInput[k,2]*7,width=7)," 0.00 ",format(WellInput[k,3],width=8))
operation2<-paste0(" ",format(month(Z[i*7-6+1,0]),width=2)," ",format(day(Z[i*7-6+1,0]),width=2)," 10 2 5 0.00000 0.00 0.0000 0.00 0")
mgt<-c(mgt,operation4,operation1,operation2)
} else{
operation3<-" 8 1 7 0 0.00001 0.99 "
operation1<-paste0(" ",format(month(Z[i*7-6,0]),width=2)," ",format(day(Z[i*7-6,0]),width=2)," 10 1 5 2.00000 1.00 ",format(WellInput[k,2]*7,width=7)," 0.00 ",format(WellInput[k,3],width=8))
operation2<-paste0(" ",format(month(Z[i*7-6+1,0]),width=2)," ",format(day(Z[i*7-6+1,0]),width=2)," 10 2 5 0.00000 0.00 0.0000 0.00 0")
mgt<-c(mgt,operation3,operation1,operation2)
}
}
print(i)
}