[R] xyplot: Combining 'subscripts' and 'allow.multiple=T'
Sundar Dorai-Raj
sundar.dorai-raj at pdf.com
Fri Apr 20 18:15:42 CEST 2007
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
More information about the R-help
mailing list