library(tidyverse)
########### 合并矩阵 #############
files <- list.files(pattern = '.FileFormat')
merge.data <- read.table(files[1], row.names = 1)
colnames(merge.data)[1] <- files[1]
for (i in 2:length(files)){
new.data <- read.table(files[i], row.names = 1)
colnames(new.data)[1] <- files[i]
merge.data <- cbind(merge.data, new.data)
}
########## 单个读入 ############
files <- list.files(pattern = '.FileFormat')
for (i in 1:length(files)){
new.data <- read.table(files[i], row.names = 1)
assign(files[1], new.data)
}
# use get(files[1]) to get the file content
R 读取文件夹里的文件
最新推荐文章于 2024-07-10 18:59:23 发布