[R] levelplot and source() problems

From: Niels Vestergaard Jensen <nvj_at_fys.ku.dk>
Date: Tue 13 Jun 2006 - 22:04:56 EST


I have been using levelplot but have had trouble calling it inside functions - something seems to go wrong when it's not called directly from the R command prompt. Simplest reproducible example:

$ R --vanilla
> library(lattice)
> levelplot(matrix(1:4,2,2))

Now, with a file lptest.r containing 2 lines:

library(lattice)
levelplot(matrix(11:14,2,2))

> source("lptest.r")

Gives nothing.

I've tried closing all devices and setting it with X11() and pdf().

Am I missing something here or should I file a bug report? I'm running R Version 2.2.1 (2005-12-20 r36812) on Red Hat, lattice library v. 0.12-11

With the (more complex) example where I ran into this barrier I also debugged the function calling levelplot. I could call levelplot from the browser with nice results, but when the function executed the exact same command in the next moment nothing happened.

I've pasted the output of debug(levelplot) when sourcing lptest.r below, it's very much like what went on in the more complex example.

best

        Niels

Debugging levelplot:

> library(lattice)
> debug(levelplot)
> source("lptest.r")

[1] "test"
debugging in: levelplot(matrix(11:14, 2, 2)) debug: {

    ocall <- match.call()
    formula <- ocall$formula
    if (!is.null(formula)) {

        warning("The 'formula' argument has been renamed to 'x'. See ?xyplot")

        ocall$formula <- NULL
        if (!("x" %in% names(ocall)))
            ocall$x <- formula
        else warning("'formula' overridden by 'x'")
        eval(ocall, parent.frame())

    }
    else UseMethod("levelplot")
}
Browse[1]>
debug: ocall <- match.call()
Browse[1]>
debug: formula <- ocall$formula
Browse[1]>
debug: if (!is.null(formula)) {

    warning("The 'formula' argument has been renamed to 'x'. See ?xyplot")     ocall$formula <- NULL
    if (!("x" %in% names(ocall)))

        ocall$x <- formula
    else warning("'formula' overridden by 'x'")     eval(ocall, parent.frame())
} else UseMethod("levelplot")
Browse[1]>
debugging in: levelplot(form, data, aspect = aspect, ...) debug: {

    ocall <- match.call()
    formula <- ocall$formula
    if (!is.null(formula)) {

        warning("The 'formula' argument has been renamed to 'x'. See ?xyplot")

        ocall$formula <- NULL
        if (!("x" %in% names(ocall)))
            ocall$x <- formula
        else warning("'formula' overridden by 'x'")
        eval(ocall, parent.frame())

    }
    else UseMethod("levelplot")
}
Browse[1]>
debug: ocall <- match.call()
Browse[1]>
debug: formula <- ocall$formula
Browse[1]>
debug: if (!is.null(formula)) {

    warning("The 'formula' argument has been renamed to 'x'. See ?xyplot")     ocall$formula <- NULL
    if (!("x" %in% names(ocall)))

        ocall$x <- formula
    else warning("'formula' overridden by 'x'")     eval(ocall, parent.frame())
} else UseMethod("levelplot")
Browse[1]>
exiting from: levelplot(form, data, aspect = aspect, ...) exiting from: levelplot(matrix(11:14, 2, 2)) >



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jun 13 22:17:29 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 14 Jun 2006 - 00:15:07 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.