[R] levelplot and source() problems

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jun 13 14:19:12 CEST 2006


This is 7.22 of the R FAQ:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f

On 6/13/06, Niels Vestergaard Jensen <nvj at fys.ku.dk> wrote:
> 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))
> >
>
> ______________________________________________
> R-help at 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
>



More information about the R-help mailing list