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 sameelse
,else
not correct - you not close
if
statement beforeelse
. - there no need loop on columns explicitly
Comments
Post a Comment