On Tue, 23 Dec 2003, Rafael A. Irizarry wrote:

> Using Sweave in the tools library (R version 1.8.0: sorry i havent
> upgraded), it seems i cant use if statements in R chunks that make graphs.
> i have this:
>
> <<fig=TRUE,echo=F>>=
> par(mfrow=c(1,1))
> if(exists("x"))
>       plot(x,x)
> else{
>   plot(1,1,type="n")
>   text(1,1,"data not available.\n")
> }
> @
>

I think your problem is with the `else'.  The `if' part of the statement
is syntactically complete, so the parser isn't expecting an `else'.  You
need something like

  if (exists("x")){
        plot(x,x)
  } else {
        plot(1,1,type="n")
  }



        -thomas

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to