0
我想在R中創建一個批處理腳本來預處理一些數據,我必須做的第一步之一是檢查一個文件是否存在於一個子文件夾中,目錄,然後(如果有)用新名稱創建它的副本。我在語法上遇到了麻煩。使用R來循環子目錄和複製文件
這是我的代碼:
##Define the subject directory path
sDIR = "/home/bsussman/Desktop/WORKSPACE"
#create data frame to loop through
##list of subject directories
subjects <-list.dirs(path = sDIR, full.names = TRUE, recursive = FALSE)
for (subj in 1:length(subjects)){
oldT1[[subj]] <- dir(subjects[subj], pattern=glob2rx("s*.nii"), full.names=TRUE)
T1[[subj]] <- paste(subjects[subj], pattern="/T1.nii",sep="")
if (file.exists(paste(subjects[subj], pattern="/T1.nii",sep=""))=FALSE{
file.copy(oldT1, T1)
}
}
它重命名文件在一個子目錄,而是通過不會做循環給了我這些錯誤:
Error: unexpected '=' in:
"
if (file.exists(paste(subjects[subj], pattern="/T1.nii",sep=""))="
> file.copy(oldT1, T1)
[1] FALSE
> }
Error: unexpected '}' in " }"
> }
Error: unexpected '}' in "}"
我不是儘可能多的擔心[ 1] FALSE消息。但是有什麼想法?
謝謝!
謝謝您的幫助! – bsuss 2014-11-03 19:41:05