[R] how to use conditional statements to handle exceptions?
Andy Bunn
abunn at montana.edu
Tue Mar 9 19:23:14 CET 2004
If you mean to put a check in to see if the file exists then something
like this would work:
for(i in 1:3){
aFile <- paste("file", i, ".dat", sep = "")
if(file.exists(aFile) == T){
bb <- read.table(aFile, header = F)
x11()
plot(bb)
dev.off()
}
}
If you mean that you want to check to see that it has data in it you
could ammend the if statement to something like
if(nrow(aFile) > 0)...
HTH, Andy
More information about the R-help
mailing list