[R] levelplot and source() problems

Niels Vestergaard Jensen nvj at fys.ku.dk
Tue Jun 13 14:04:56 CEST 2006


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))

- This gives a nice plot in soothing pastel colors.

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))
>



More information about the R-help mailing list