对于循环替换,R中的长度为零

时间:2020-07-18 03:01:47

标签: r

循环有点问题。这是循环的代码:

for(i in 2 : seq_along(dfpl$jobid_c)){
  if ((dfpl$jobid_c[i]>0) & (dfpl$job_id[i]==0)  ){
    j = (i-1)
    dfpl$formula_code[i] = dfpl$formula_code[j] 
    dfpl$formula_date[i] = dfpl$formula_date[j] 
    dfpl$formula_name[i] = dfpl$formula_name[j]
  }
  else{ 
    
  }
}  
Error in dfpl$formula_code[i] <- dfpl$formula_code[j] : 
  replacement has length zero
In addition: Warning message:
In 2:seq_along(dfpl$jobid_c) :
  numerical expression has 4205 elements: only the first used

0 个答案:

没有答案