if (0.1>RATE=>0){wthistory=0} else if(0.3>RATE=>0.1){wthistory=5} else if(0.5>RATE=>0.3){wthistory=10} else if(0.7>RATE=>0.5){wthistory=15} else if(0.9>RATE=>0.7){wthistory=15} else{wthistory=30}
R語言中支持 else if 的判斷,但是上面的寫法是錯誤的
R無法判斷 if 對應的else 在何處結尾
修改如下
if (0.1>RATE&RATE>=0){wthistory=0 } else if(0.3>RATE&RATE>=0.1){wthistory=5 } else if(0.5>RATE&RATE>=0.3){wthistory=10 } else if(0.7>RATE&RATE>=0.5){wthistory=15 } else if(0.9>RATE&RATE>=0.7){wthistory=15 } else{wthistory=30}
這里的每個else if 都接在上一句的}后面
注意最后的else也需要銜接在上一句的}后面