[R] plotting an expression

apjaworski@mmm.com apjaworski at mmm.com
Tue May 1 00:20:56 CEST 2001

I am sure it is just me not understanding how R works, but could somebody
explain why


works and


does not?

I have done some investigating and here is what I found.  If I comment out
the line of curve indicated below, both calls work fine.

function (expr, from, to, n = 101, add = FALSE, type = "l", ylab = NULL,
    log = NULL, xlim = NULL, ...)
    sexpr <- substitute(expr)
    if (is.name(sexpr)) {
        fcall <- paste(sexpr, "(x)")
        expr <- parse(text = fcall)
        if (is.null(ylab))
            ylab <- fcall
    else {
        if (!(is.call(sexpr) && match("x", all.vars(sexpr), nomatch = 0)))
            stop("'expr' must be a function or an expression containing
 #     expr <- sexpr
        if (is.null(ylab))
            ylab <- deparse(sexpr)
    lims <- if (is.null(xlim))
    < ... >

This is confusing, since


returns just


Must be some side effects I do not understand.  What is even more confusing
is that the above code (with one line commented out) does not work when
called as






What I am really trying to do is plot a rather compilcated expression that
has been built from pieces by pasting strings together.  SInce the parse
function returns an expression I thought I could just feed the result of
parse to plot ( or curve).

Any help or explanation will be appreciated,


r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list