请问一下怎么同时取首尾的数值

请问一下怎么同时取首尾的数值,想取前20个和后20个,但是cbind之后变成两列数据了


rt=read.table(inputFile, header=T, sep="\t", check.names=F, row.names=1)  
GAIN=rowSums(rt> 0)       
LOSS=rowSums(rt< 0)        
LOSS=LOSS/ncol(rt)*100 
top_genes <- sort(GAIN, decreasing = TRUE)[1:20]
top_genes2 <- sort(GAIN, decreasing = TRUE)[47:67]
top<-cbind(top_genes,top_genes2,)
buttom_genes <- sort(LOSS,decreasing = TRUE)[1:20][47:67]

“Devil组”引证GPT后的撰写:
可以分别取前20个和后20个,再用rbind()函数将它们合并成一个数据框

top_genes <- sort(GAIN, decreasing = TRUE)[1:20]
top_genes2 <- sort(GAIN, decreasing = TRUE)[47:67]
top <- rbind(head(top_genes, 20), tail(top_genes2, 20))
buttom_genes <- sort(LOSS,decreasing = TRUE)[1:20]
bottom_genes2 <- sort(LOSS,decreasing = TRUE)[47:67]
bottom <- rbind(head(buttom_genes, 20), tail(bottom_genes2, 20))


这样,top和bottom都是一个包含前20个和后20个数值的数据框。