我必须做一个重复表,每次计算都要取上一个.让我解释一下,我最初的数据是:
maximum <- 10
minimum <- 2
orderp <-0
Qst <- 6
sell <- c(0, 2 , 2 , 10)
计算:
Qst <- c(6, 4, 2, 0)
Qfin <- c(6,4, 10, 10)
orderp <- c(0,0,8,10)
output<-data.frame(Qst,Qfin,sell)
Name | 1 | 2 | 3 | 4 |
---|---|---|---|---|
Qst | 6 | 6-2=4 (Qfin(1)-sell(2) | 4-2=2 (Qfin(2)-sell(3) | 10-10=0 (Qfin(3)-sell(4) |
orderp | 0 | 0 if(Qst(2) <=min) MAX-Qst(2) | 8 if(Qst(3) <=min) MAX-Qst | 10 if(Qst(4) <=min) MAX-Qst |
Qfin | 6 | 4 (Qst(2)+orderp(2) | 10 (Qst(3)+orderp(3) | 10 (Qst(4)+orderp(4) |
sell | 0 | 2 | 2 | 10 |
我怎么能做这样的事?Excel很简单,但R不是我的专业.