[R] lattice: strip panel function question

Chris Campbell ccampbell at mango-solutions.com
Mon Dec 6 11:08:23 CET 2010

Dear Maarten

xyplot has the argument groups which allows you to create nested

data$subjectID <- paste(data$groups, data$subjects) # create a character

xyplot(responses~time|subjectID, groups = groups, data = data,
# or change to a factor to define the plot order

Hope this helps.

Chris Campbell

MANGOSOLUTIONS, R Consulting and Training
T: +44 (0)1249 767700 Ext: 233
F: +44 (0)1249 767707
M: +44 (0)7967 028876

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Maarten van Iterson
Sent: 06 December 2010 08:32
To: r-help at r-project.org
Subject: [R] lattice: strip panel function question

Dear list, 

If have some repeated measurement data which looks something like: 

time <- rep(1:5 , each=2*4)
groups <- rep(c("Case", "Control"), each=4)
subjects <- factor(rep(1:(2*4), 5))
responses <- time + rnorm(5*2*4) + as.integer(factor(groups))
data <- data.frame(responses, time, groups, subjects)

Now I want to plot each subject in a separate panel:

xyplot(responses~time|subjects*groups, data = data, aspect="xy")

but this introduces empty panels. I tried this:

data$subjectID <- factor(rep(1:4, 2*5))
xyplot(responses~time|subjectID*groups, data = data, aspect="xy")

This is what I want but now I don't have the correct subject id's. I
couldn't find a solution in the help of strip.default.

Does anyone has a solution to this?

Thanks in advance, 


> sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: x86_64-unknown-linux-gnu (64-bit)

 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods

other attached packages:
[1] lattice_0.19-13

loaded via a namespace (and not attached):
[1] grid_2.12.0  tools_2.12.0

Maarten van Iterson
Center for Human and Clinical Genetics
Leiden University Medical Center (LUMC)
Research Building, Einthovenweg 20 
Room S-04-038
Phone: 071-526 9439
E-mail: M.van_iterson.HG at lumc.nl
Postal address:
Postzone S-04-P
Postbus 9600
2300 RC Leiden 
The Netherlands

R-help at r-project.org mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
This message is intended for the use o...{{dropped:9}}

More information about the R-help mailing list