On Mon, Mar 12, 2012 at 4:39 AM, Alaios <ala...@yahoo.com> wrote:
> 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

______________________________________________
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.

Reply via email to