【发布时间】:2017-02-06 23:18:21
【问题描述】:
我正在尝试对多个文件执行一个功能,我正在使用这个:
require(readxl);
require(MESS);
final_df <- NULL;
for(i in CHI.Files){
PPeakD <- read_excel(paste0('/Users/andrewmclean/Dropbox/Research/Andrew/
LungStudyOutput - Whole case/',i), sheet = "Ppeak");
PPeakD <- PPeakD[c(4,5)]
colnames(PPeakD)<-c("Time","PPeak")
PPeakD <- PPeakD[c(which(PPeak$PPeak>0)),]
PEEP <- read_excel(paste0("~/Dropbox/Research/Andrew/
LungStudyOutput - Whole case/",i),
sheet = "PEEP")
PEEP <- PEEP[c(4,5)]
colnames(PEEP)<-c("Time","PEEP")
PEEP <- PEEP[c(which(PEEP$PEEP>0)),]
PPeakAdj <- CHI.Files.frame(approx(PPeak$Time, PPeak$PPeak,
xout = PEEP$Time, method = "linear", rule = 2))
colnames(PPeakAdj)<-c("Time","PPeakAdj")
DrivP <- CHI.Files.frame((PPeakAdj$Time),((c(PPeakAdj$PPeakAdj)) - (c(PEEP$PEEP))))
colnames(DrivP) <- c("Time", "DrivP")
final_df <- rbind(final_df,DrivP)
}
但是,当我这样做时,我只会收到以下消息:
In addition: Warning messages:
1: In if (!file.exists(path)) { :
the condition has length > 1 and only the first element will be used
2: In if (!is_absolute_path(path)) paste0(" in current working directory ('", :
the condition has length > 1 and only the first element will be used
寻找任何关于我做错了什么的建议?
谢谢
编辑: 使@Jonathan Carroll 的更正错误代码如下所示:
Error: '/Users/andrewmclean/Dropbox/Research/Andrew/
LungStudyOutput - Whole case/013234-1.xls/Users/andrewmclean/Dropbox/Research/Andrew/
LungStudyOutput - Whole case/006538-1.xls/Users/andrewmclean/Dropbox/Research/Andrew/
LungStudyOutput - Whole case/000478-1.xls/Users/andrewmclean/Dropbox/Research/Andrew/
LungStudyOutput - Whole case/025396-1.xls/Users/andrewmclean/Dropbox/Research/Andrew/
LungStudyOutput - Whole case/045495-1.xls/Users/andrewmclean/Dropbox/Research/Andrew/
LungStudyOutput - Whole case/000443-1.xls/Users/andrewmclean/Dropbox/Research/Andrew/
LungStudyOutput - Whole case/020462-1.xls/Users/andrewmclean/Dropbox/Research/Andrew/
LungStudyOutput - Whole case/080677-1.xls/Users/andrewmclean/Dropbox/Research/Andrew/
In addition: Warning messages:
1: In if (!file.exists(path)) { :
the condition has length > 1 and only the first element will be used
2: In if (!is_absolute_path(path)) paste0(" in current working directory ('", :
the condition has length > 1 and only the first element will be used
【问题讨论】:
-
我不知道
CHI.Files中有什么,但从它的外观来看,不仅仅是一个值。在循环之前注释掉循环,看看你是否可以让它为单个文件工作。在每一步检查变量的内容,确保它们是你所想的。 -
是的,它没有跳出循环。我认为问题在于我的数据被“平衡”了,因此它试图将太多数据放入......