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 to replace columns with NA and removing those where there are too many NA.