Hi all, I have a very large number of vectors that I want first to look fast which distribution might be considered candidate for fitting. I made a simple loop that checks for all vector (the code below is for one vector and being called for each vector separately). If a good fit is found this is dumped to a txt file so to allow me later on, see results
distList<-c("norm","exp","gamma","lnorm") for (dist in distList) { if (gofstat(fitdist(onVector,distr=dist))$kstest =="not rejected"){ # keep it out<-capture.output(gofstat(fitdist(onVector,distr=distr))$ks) print(sprintf("Saving to file %s ",filename)) cat(out,file=paste(filename,".txt",sep=""),sep="\n",append=TRUE) } } the major problem is that these for loops return errors (sometimes for a given vector a specific distribution does not make sense or the vector might be zero or containing only many times the same element) . The easiest would be in errors and warning just move to the next element of the for loop. Something like that for () { if error==skip to next element else do normal stuff } how I can do that in R? Regards Alex [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.