Skip to content
Prev 387786 / 398502 Next

Looping through data error

Hello,

A close parenthesis is missing in the nd if.


for (i in 1:(nrow(PLC_Return)-1)){
   if (i == 1){
     NUMBER_OF_SHARES[i] = 100/is.na(CLOSE_SHARE_PRICE[i])
   } else if(is.na(PLC_Return[i, 1]) == is.na(PLC_Return[i + 1, 1])){
     NUMBER_OF_SHARES[i]=0
   } else {
     NUMBER_OF_SHARES[i] = 100/is.na(CLOSE_SHARE_PRICE[i])
   }
}


Hope this helps,

Rui Barradas

?s 13:51 de 13/04/21, e-mail ma015k3113 via R-help escreveu: