Thanks a lot for the answer.. As you can see my chain is the following open a pdf device. plot and
close the device pdf(file=filename, width=width) try(plot_per_band_ (list(get(varlist[[k]])), i, j,meanPlot=TRUE)) dev.off() I would like if plot fails (so try returns try-error) the file to not be created. How should I think doing that in R? B.R Alex ________________________________ From: Sarah Goslee <sarah.gos...@gmail.com> Cc: R help <R-help@r-project.org> Sent: Monday, March 12, 2012 12:24 PM Subject: Re: [R] resume on error > Thanks a lot. > How I can use try though for plots. There are times where the plot function > will fail > > pdf(file=filename, width=width) > try(plot_per_band(list(get(varlist[[k]])), i, j, l, > datalabels=seq(1:length(varlist)))) > dev.off() > > the code above does not print anything. That's a long way from a reproducible example. What do you expect to happen if plot() fails? Assign the output of try() to an object. Check whether that object is of class "try-error" and if so, do whatever you want the failure case to be. Sarah > B.R > Alex > > > > ________________________________ > From: R. Michael Weylandt <michael.weyla...@gmail.com> > > Cc: R help <R-help@r-project.org> > Sent: Sunday, March 11, 2012 12:56 AM > Subject: Re: [R] resume on error > > ? try or ? tryCatch > > Michael > > >> Dear all, >> I would like to ask you how I can catch an error on R and then ask it to >> resume. >> >> For example I have a large for loop and I know for a small number inside >> that loop there will be errors. How I can ask in that case from R just to >> ignore it and return back to the loop? >> >> I would like to thank you in advance fro your help >> >> B.R >> Ale >> -- Sarah Goslee http://www.functionaldiversity.org [[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.