R: calculate prevalence


统计丰度>0.0001的细菌的出现率

target="China"
tmp=df[which(df$Country==target),]
n_row=nrow(tmp)
rate=c()
for(i in 3:529)
{
    rate=c(rate, nrow(tmp[tmp[,i]>0.0001,])/n_row)
}
out_china=data.frame(Country=rep("China",527),
                     Genome=colnames(tmp)[3:529],
                     Prevalence=rate)

你可能感兴趣的:(R: calculate prevalence)