R which

 1 setwd("E:/courses/molecular biology/homework1st")
 2 genes <- read.table('genes.txt',sep = '	',header = T)
 3 
 4 chrID<-c("chr1","chr2","chr3","chr4","chr5","chr6","chr7","chr8","chr9","chr10","chr11","chr12",
 5          "chr13","chr14","chr15","chr16","chr17","chr18","chr19","chr20","chr21","chr22","chrX","chrY")
 6 pro_counts=vector()
 7 for(chr in chrID){
 8   chr<-genes[genes$chrom==chr,]
 9   protein_coding<-chr$cdsEnd-chr$cdsStart
10   pro_counts<-c(pro_counts,length(which(protein_coding>0)))
11 }
原文地址:https://www.cnblogs.com/shanyr/p/11523508.html