Ich versuche, die Durchführung einer Funktion auf mehrere Dateien zu tun, und ich bin mit diesem:Warnmeldung bei Verwendung if()
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)
}
Wenn jedoch ich nur ich die folgende Meldung:
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
Suchen Sie einen Rat, was ich falsch mache?
Dank
edit: gemacht @ Jonathan Carroll ‚s Fehlerkorrektur-Code sieht wie folgt aus:
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
Ich habe keine Ahnung, was in 'CHI.Files' ist, aber nach dem Aussehen, nicht nur ein einzelner Wert. Kommentieren Sie die Schleife und sehen Sie, ob Sie es für eine einzelne Datei arbeiten lassen können, bevor Sie Dinge loopen. Überprüfen Sie den Inhalt der Variablen bei jedem Schritt und stellen Sie sicher, dass sie Ihren Vorstellungen entsprechen. –
Ja, es hat nicht aus der Schleife funktioniert. Ich denke, das Problem war, dass meine Daten "nivelliert" wurden und so versuchte ich, zu viele Daten in ... – andyroo