0

Hi can anyone help on the codes below? I keep getting error message "Error in splitdata[[i]] : subscript out of bounds". But splitdata is a list with 54 elements. Any advice appreciated.

for (i in (1:54)){
  if(rank == "best"){
    column1[i]<-splitdata[[c(i,1)]]
  }else if(rank == "worst"){
    column1[i]<-splitdata[[c(i,length(splitdata[[i]]))]]
  }else if(rank > length(splitdata[[i]])){
    column1[i]<-"NA"
  }else{
    column1[i]<-splitdata[[c(i,rank)]]}}
lcwlwc
  • 1
  • 1
    http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Metrics Feb 25 '15 at 04:15
  • 1
    check `length(splitdata)` and `i`. Other than that, see the previous comment. – Jthorpe Feb 25 '15 at 04:24
  • Post `str(splitdata)` ... and is rank supposed to vary with 'i'? At the moment it looks like it would always have the same value. – IRTFM Feb 25 '15 at 05:46

0 Answers0