我正在尝试对多个文件执行一个函数,我正在使用它:
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
答案 0 :(得分:0)
据推测,这应该围绕其内容paste
,因为它目前正试图提供太多参数
PEEP <- read_excel("~/Dropbox/Research/Andrew/
LungStudyOutput - Whole case/",CHI.Files[i], sep='',
sheet = "PEEP")