[R] labels in lattice

matteo dossena m.dossena at qmul.ac.uk
Wed Dec 14 23:03:13 CET 2011


Thanks David and Patrick,

really appreciate tour help...

m.


Il giorno 14 Dec 2011, alle ore 18:33, David Winsemius ha scritto:

> 
> On Dec 14, 2011, at 11:43 AM, matteo wrote:
> 
>> set.seed(3)
>> mydata <- data.frame(var = rnorm(100,20,1),
>>                   temp = sin(sort(rep(c(1:10),10))),
>>                   subj = as.factor(rep(c(1:10),5)))
>> 
>> and I need to make a scatter plot for each subj, not a problem, but...
>> what i want is to replace the strips from the lattice and add a label to
>> each plot.
>> I manage to do this with the following code, but I'm still not happy...
>> 
>> xyplot(var ~ temp | subj,
>>     data = mydata,
>>     strip=FALSE,
>>     panel = function(x, y,...) {
>>             panel.xyplot(x, y,...)
>>             panel.text(1,21,labels=which.packet())
> 
> Instead use the packet numer a an index into `letters`
> 
>              panel.text(1,21,labels=letters[which.packet()])
> 
>>             })
> 
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>



More information about the R-help mailing list