[R] Access to conditioning variables (lattice)

Martin D. Lepage martin.d.lepage at gmail.com
Thu Sep 24 16:37:51 CEST 2009


[using R version 2.8.1 (2008-12-22)]

Hello,

I'm trying to access the conditioning variables of an xyplot within a
'panel' function but I have not been able to figure out how to do so.
Here is a simple example that describes what I wish to do (the problem
lies with the commented line):

dataset <- data.frame(x = c(1,2), y = c(4,5), Type = factor(c("a","b")))
xyplot( y ~ x | Type, dataset, 
        panel = function(...) {
            panel.xyplot(...)
#           do_something_with(conditioning_variables[which.packet()])
        })

The problem I am facing is that I do not know how to generically access
the conditioning variables within the panel function. In this simple
case, I can achieve what I want to do with the following call :

    do_something_with(Type[which.packet()])

but that requires the panel function call to have prior knowledge of the
object used as the conditioning variable, which is not flexible enough
for my needs.

Thank you,
Martin D. Lepage




More information about the R-help mailing list