小弟又来请教问题
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