1、
test <- read.table("a.txt", as.is = T) test index <- read.table("cols",as.is = T) index index <- as.vector(t(index)) index test2 <- test[,index] test2