小弟又來請教問題
mutate(.,MA10t=SMA(Ct,10),
MA10lower=as.numeric(Ct<MA10t),
MA10down=as.numeric(MA10lower==1&lag(MA10lower)==0),
MA10down1=ifelse(lead(MA10down,1)==0,0,lead(Ct,1)),
MA10down2=ifelse(lead(MA10down,2)==0,0,lead(Ct,2)),
MA10down3=ifelse(lead(MA10down,3)==0,0,lead(Ct,3)),
MA10down4=ifelse(lead(MA10down,4)==0,0,lead(Ct,4)),
MA10down5=ifelse(lead(MA10down,5)==0,0,lead(Ct,5)),
MA10down6=ifelse(lead(MA10down,6)==0,0,lead(Ct,6)),
MA10down7=ifelse(lead(MA10down,7)==0,0,lead(Ct,7)),
MA10down8=ifelse(lead(MA10down,8)==0,0,lead(Ct,8)),
MA10down9=ifelse(lead(MA10down,9)==0,0,lead(Ct,9)))
請問各位 我想要創建column 直到
MA10down60=ifelse(lead(MA10down,60)==0,0,lead(Ct,60))
不知是否有什麼好方法呢?
再者有個情況是
pmin(MA10down1,MA10down2,MA10down3,MA10down4,
MA10down5,MA10down6,MA10down7,MA10down8,MA10down9,MA10down10...MA10down60)
有什麼方法可以巧妙把60個用精簡的語法一次選取起來?
感謝各位QQ