Draw Function Plots
Usage
curve(expr, from, to, n=101, ...)
Arguments
expr
|
an expression, written as a function of
x which will be plotted.
|
from,to
|
the range over which the function will be plotted.
|
n
|
the expression will be evaluated at n
points equally spaced over the range [from, to] .
The points determined in this way are then joined with
straight lines.
|
...
|
graphical parameters can also be specified as arguments.
|
Description
This function draws a curve corresponding to the
given expression (in x
) over the interval
[from,to]
.
It is a quick hack which seems to serve a useful purpose,
but can give bad results for functions which are
discontinuous.Value
NULL
. For ``expensive'' expr
essions, you should smarter tools.See Also
splinefun
for spline interpolation, lines
.Examples
curve(x^3-3*x, -2, 2)
curve(x^2-2, add = TRUE, col = "violet")