I'm terribly confused on how to use try catch to continue execution within
a loop

I take, say, the data for 150 symbols from yahoo, and seek to parse them
and append to existing index files in csv format. Sometimes the data is
bad, the code pukes inside the loop and execution stops, as evident here:

[109] "^BVSP - 20140324,47381.98,48141.789,47381.98,47993.422,0"
[110] "^GSPTSE - 20140324,14335.76,14402.49,14226.88,14278.55,163174560"
[111] "^N225 - 20140324,0,0,0,14475.3,0"
[112] "CAC4L.NX - 20140324,N/A,N/A,N/A,0,N/A"
[113] "^BSESN - 20140324,N/A,N/A,N/A,0,N/A"
Error in value[[3L]](cond) : unused argument(s) (cond)
Calls: tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
In addition: Warning message:
In if (file == "") file <- stdout() else if (is.character(file)) { :
  the condition has length > 1 and only the first element will be used
Execution halted

Below is the code I am using, where i use tryCatch() to continue execution
within the loop, but for whatever reason, it still breaks out of the loop
on an error. Can someone please point out the error of my ways here? Thanks
, Ralph Vince

j <- "http://finance.yahoo.com/d/quotes.csv?s=";
for (i in 1:150) {
    j <- paste(j,brsym[[i]],sep="+");
}
j <- paste(j,"&f=sd1ohgl1vqd",sep="");
print(j);
X <- read.csv(j, header=FALSE,as.is=TRUE);
#print(X);
for (i in 1:150) {
    tryCatch({
        d<-strsplit(X[i,2], '/');
        dd<-d[[1]][3];
        if (as.numeric(d[[1]][1]) < 10){
          dd<-paste(dd,0,sep="");
        }
        dd<-paste(dd,d[[1]][1],sep="");
        if (as.numeric(d[[1]][2]) < 10){
          dd<-paste(dd,0,sep="");
        }
        dd<-paste(dd,d[[1]][2],sep="");
        dd<-paste(dd,X[i,3],sep=",");
        dd<-paste(dd,X[i,4],sep=",");
        dd<-paste(dd,X[i,5],sep=",");
        dd<-paste(dd,X[i,6],sep=",");
        dd<-paste(dd,X[i,7],sep=",");
        ko <- paste(X[i,1], "-",dd);
        print(ko);

        k <- paste("/home/rvince/AsciiCsv/ES50/", X[i,1], sep="");
        k <- trim.whitespace(k);
        k <- paste(k,".csv", sep="");
        write.table(dd, k, append = TRUE, quote = FALSE, sep = ",",
                    eol = "\n", na = "0", dec = ".", row.names = FALSE,
                    col.names = FALSE, qmethod = c("escape", "double"));
    }, error = function() next)
}

	[[alternative HTML version deleted]]

