[R] Continue R CMD BATCH on error

jim holtman jholtman at gmail.com
Mon Apr 13 14:03:10 CEST 2009


?try

On Mon, Apr 13, 2009 at 5:14 AM, Andreas Wittmann
<andreas_wittmann at gmx.de> wrote:
> Dear R useRs,
>
> after searching r-help and r-manuals for about one hour i have the
> following, probably easy question for you.
>
> i have the following R-code, in the file test01.R
>
> ################################################################################
>
> `fun1` <- function(x)
> {
>  x <- x + 2
>
>  if(x == 5)
>   stop("failure")
>
>  return(x)
> }
>
> `fun2` <- function(x)
> {
>  x <- x + 4
>
>  return(x)
> }
>
> x <- 1:10
> val1 <- val2 <- numeric(10)
>
> for(i in 1:10)
> {
>  val1[i] <- fun1(x[i])
> }
>
> for(i in 1:10)
> {
>  val2[i] <- fun2(x[i])
> }
>
> ################################################################################
>
> then i want to do
>
> R CMD BATCH test01.R
>
> the result file test01.Rout does not contain the computation of val2 and it
> stops in the for loop of val1.
> how can i avoid this and continue the computation on error?
>
> best regards
>
> Andreas
>
> ______________________________________________
> R-help at 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list