r - Error in for loop -


k<-21;  for(i in 5:k) { pharma[,i][pharma[,i]=="#n/a"]<- na pharma[,i][pharma[,i]=="nm"]<- na num<-sum(is.na(pharma[,i])) n=1-num/length(pharma[,i])  if(n<0.8) { rm(pharma[,i]) else n=0 } } 

basically trying replace columns na , removing there many na.

you did not tell error code creates. several observations:

  • r case sensitive. else not same else , else not correct
  • you not close if statement before else.
  • there no need loop on columns explicitly

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -