Ah, wonderful, thank you for the code Deepayan. To recap for posterity: I 
have two datafiles, d and q: each has x-y coordinates that are conditioned 
by site (The actual data, for me, is maps of parent trees and their 
seedlings). I wanted to superimpose the xy plots of d and q, by site, 
without going to the trouble of merging the d & q datasets into a single 
dataset. The solution is to use the "which.packet" statement is 


d <- data.frame(site  = c(rep("A",12), rep("B",12)), 
x=rnorm(24),y=rnorm(24))                # Create the main xy dataset
q <- data.frame(site  = c(rep("A",7), rep("B",7)), 
x=rnorm(14),y=rnorm(14))                # Create the alternate xy dataset


q.split <- split(q, q$site)                     # Split up the alternate 
dataset by site

mypanel <- function(..., alt.data) {
    with(alt.data[[ which.packet()[1] ]],                       # 
which.packet passes index of the relevant data subset...
         panel.xyplot(x = x, y = y, col="red"))                 # ... to 
panel.xyplot()
    panel.xyplot(...)
}

xyplot(y ~ x | site, d, alt.data = q.split,             # After providing 
the alternative dataset and the panel...
       panel = mypanel)                         # ...everything prints out 
properly, like magic!



Dr. Seth  W. Bigelow
Biologist, USDA-FS Pacific Southwest Research Station
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to