R 循环每个子文件夹
这是我的代码:R 循环每个子文件夹,r,loops,R,Loops,这是我的代码: setwd("folder/subfolder1") Data <- ReadAffy() eset<-rma(Data) write.expres(eset, file="subfolder1.txt") setwd(“文件夹/子文件夹1”) 数据这个怎么样: # get into the parent directory setwd("folder") # loop through the sub directories (use [-1] to lop off
setwd("folder/subfolder1")
Data <- ReadAffy()
eset<-rma(Data)
write.expres(eset, file="subfolder1.txt")
setwd(“文件夹/子文件夹1”)
数据这个怎么样:
# get into the parent directory
setwd("folder")
# loop through the sub directories (use [-1] to lop off the current directory: ".")
for (dir in list.dirs()[-1]) {
# get into the sub directory
setwd(dir)
# do the do
Data <- ReadAffy()
eset<-rma(Data)
# build the file name by pasting ".txt" on the end of the directory name
write.expres(eset, file=paste(dir, "txt", sep="."))
# pop back up to the parent directory
setwd("../")
}
#进入父目录
setwd(“文件夹”)
#循环遍历子目录(使用[-1]删除当前目录:“.”)
for(list.dirs()[-1]中的目录){
#进入子目录
setwd(dir)
#照办
通过list.dirs()
返回的目录名向量进行数据循环。