说我有以下文件:
File1.dat
File2.dat
File3.dat
File4.dat
.
.
.
File50.dat
以及以下目录:
M1_Para1_Stand1
M1_Para1_Stand2
M1_Para1_Stand3
M1_Para2_Stand1
.
.
.
M2_Para6_Stand3
现在我想File1
进入M1_Para1_Stand1
,File2
进入M1_Para1_Stand2
,File50
进入M2_Para6_Stand3
等等。像这样:
M1_Para1_Stand1/File1.dat
M1_Para1_Stand2/File2.dat
M1_Para1_Stand3/File3.dat
M1_Para2_Stand1/File4.dat
.
.
.
M2_Para6_Stand3/File50.dat
有没有办法通过列表来做到这一点? 目前我正在使用file.copy,但那有点烦人......
感谢您的回复
答案 0 :(得分:0)
我不确定这是否是你想要的但也许有帮助:
##Dummy Data##
x <- data.frame(a=1:5,b=5:1)
files <- do.call(list, replicate(5,x,simplify=FALSE))
##Create Folders##
folders <- paste0("Your_Path/folder_",1:5,"/")
lapply(seq_along(folders), function(x) dir.create(folders[x]))
##Write Data##
lapply(seq_along(files),function(x) write.table(files[[x]],paste0(folders[x],"file",x,".dat")))