I'm not certain, but since you are getting a parse error, I would try
curly brackets on your if statement:
    <<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")
    }
    @
HTH,
+ seth