簡體   English   中英

將文件列表中的第一個文件放入文件夾列表的第一個文件夾中

[英]Getting first file in a list of files into the first folder of a list of folders

說我有以下文件:

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

現在,我想獲得File1M1_Para1_Stand1File2M1_Para1_Stand2File50M2_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,但這有點煩人...

感謝您的答復

我不確定這是否是您想要的,但也許有幫助:

##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")))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM