The answer to your first question is
curve(ifelse((x>-1)&(x<1),x^2+1,x+2),from=-10,to=10)
Sorry I cannot understand the next part of your query.
Ross Darnell
On Sun, 2007-09-02 at 00:31 -0700, JHawk3 wrote:> Hi all,
>
> I'm a relatively new user to the R interface, and am trying to do some
basic
> operations. So far I've used the curve() command to plot graphs. This
has a
> couple of limitations, namely trying to do piecewise graphs. Basically,
I'm
> looking for how to do "if" and "while" loops for making
a graph.
>
> in simple code, something like:
>
> if x is on the interval [-1,1], x=x^2+1
> otherwise, x=x^2
>
> something along those lines. I also am wondering if it's possible to
graph
> something like this:
> while(n<20)
> {
> curve(1/n^2, -1,1)
> n++
> }
> Along these same lines, is there a way to graph finite series?
>
> Thank you for your time and your replies.
>