Søren Højsgaard
2007-Apr-20 10:57 UTC
[R] xyplot: Combining 'subscripts' and 'allow.multiple=T'
Dear all, Consider this plot
xyplot(Sepal.Length + Sepal.Width ~ Petal.Length | Species,
data = iris, allow.multiple=T, outer=F,
panel = function(x,y,...) {
panel.xyplot(x,y,...)
}
)
I want to *add* some things to each panel and what I want to add involves using
the data for each panel, so I try to take this subset of data out with
subscripts:
xyplot(Sepal.Length + Sepal.Width ~ Petal.Length | Species,
data = iris, allow.multiple=T, outer=F,
panel = function(x,y,subscripts,...) {
panel.xyplot(x,y,...)
subiris <- iris[subscripts,] # Something using this ...
}
)
and then I get
Error in NextMethod("[") : argument "subscripts" is missing,
with no default
Does anyone know how to obtain this??
By the way: The doc on xyplot says: "The value of subscripts becomes
slightly more complicated when allow.multiple is in effect. Details can be found
in the source code of the function latticeParseFormula.". Sure.
Best regards
Søren
[[alternative HTML version deleted]]
Sundar Dorai-Raj
2007-Apr-20 16:15 UTC
[R] xyplot: Combining 'subscripts' and 'allow.multiple=T'
S?ren H?jsgaard said the following on 4/20/2007 3:57 AM:> Dear all, Consider this plot > > xyplot(Sepal.Length + Sepal.Width ~ Petal.Length | Species, > data = iris, allow.multiple=T, outer=F, > panel = function(x,y,...) { > panel.xyplot(x,y,...) > } > ) > > I want to *add* some things to each panel and what I want to add involves using the data for each panel, so I try to take this subset of data out with subscripts: > > xyplot(Sepal.Length + Sepal.Width ~ Petal.Length | Species, > data = iris, allow.multiple=T, outer=F, > panel = function(x,y,subscripts,...) { > panel.xyplot(x,y,...) > subiris <- iris[subscripts,] # Something using this ... > } > ) > > and then I get > Error in NextMethod("[") : argument "subscripts" is missing, with no default > > Does anyone know how to obtain this?? > > By the way: The doc on xyplot says: "The value of subscripts becomes slightly more complicated when allow.multiple is in effect. Details can be found in the source code of the function latticeParseFormula.". Sure. > > Best regards > S?ren > > [[alternative HTML version deleted]] > > > > ------------------------------------------------------------------------ > > ______________________________________________ > R-help at stat.math.ethz.ch 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.Hi, S?ren, Since you add "subscripts" to your panel arguments, you now need to explicitly pass it on to panel.xyplot. Try: xyplot(Sepal.Length + Sepal.Width ~ Petal.Length | Species, data = iris, allow.multiple=T, outer=F, panel = function(x,y,subscripts,...) { panel.xyplot(x,y,subscripts=subscripts,...) subiris <- iris[subscripts,] # Something using this ... }) HTH, --sundar