[R] lattice: defining grouping variable only for the upper/lower panel with splom

2012-11-19 Thread AnjaM
Using the mtcars dataset, how to define the grouping variable to be valid
only for the upper or lower panel?

The following doesn't work:

# Code start

splom(~data.frame(mpg, disp, hp, drat, wt, qsec),
  data=mtcars, pscales=0,
  auto.key=list(columns=3),
  upper.panel = function(...){
panel.grid(...)
panel.xyplot(groups=cyl,...)
  }
)

# Code end



--
View this message in context: 
http://r.789695.n4.nabble.com/lattice-defining-grouping-variable-only-for-the-upper-lower-panel-with-splom-tp4650033.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] lattice: defining grouping variable only for the upper/lower panel with splom

2012-11-20 Thread AnjaM
Thank you very much, this works!



--
View this message in context: 
http://r.789695.n4.nabble.com/lattice-defining-grouping-variable-only-for-the-upper-lower-panel-with-splom-tp4650033p4650144.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


[R] lattice density plot: add vertical lines at groupwise medians for all panels

2012-11-20 Thread AnjaM
Suppose you have the following code:

## Start code## 

data(Chem97, package="mlmRev")

densityplot(~gcsescore | factor(score), groups=gender, data=Chem97,
auto.key=TRUE,  plot.points=FALSE, ref=TRUE,
panel=function(x,...){
  panel.densityplot(x,...)
  median.values <- median(x) 
  panel.abline(v=median.values)}
)

##  End code## 

For some reason I don't understand, this adds only the median for one group
(in this case for gender == M) into each panel. How do I calculate and add
the medians for both groups in the right group colour?

This is what I tried:

## Start code## 

densityplot(~gcsescore | factor(score), groups=gender, data=Chem97,
auto.key=TRUE,  plot.points=FALSE, ref=TRUE,
panel=function(x,..., groups){
  panel.densityplot(x,..., groups)
  median.values <- tapply(x, groups, median) 
  panel.abline(v=median.values)}
)

##  End code## 

However, this gives an error.  What's going wrong and how can I solve this
problem?



--
View this message in context: 
http://r.789695.n4.nabble.com/lattice-density-plot-add-vertical-lines-at-groupwise-medians-for-all-panels-tp4650163.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


[R] [lattice] print only legend

2012-11-21 Thread AnjaM
Is it possible to plot (and save) only the legend of a lattice plot? Of
course I could make the axes and axis labels transparent and use an empty
panel function, but additionally to being a very "dirty" solution, there
would be still a lot of free space on the plot, while I would like to save
only the legend as a separate plot without any white space around it. Is
there a (nice) way to do this?



--
View this message in context: 
http://r.789695.n4.nabble.com/lattice-print-only-legend-tp4650269.html
Sent from the R help mailing list archive at Nabble.com.

__
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.