[R] xyplot: Combining 'subscripts' and 'allow.multiple=T'
Deepayan Sarkar
deepayan.sarkar at gmail.com
Fri Apr 20 20:42:56 CEST 2007
On 4/20/07, Sundar Dorai-Raj <sundar.dorai-raj at pdf.com> wrote:
>
>
> 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
Interesting. I get
Error in panel.superpose(x, y, type = type, groups = groups, pch = pch, :
argument "subscripts" is missing, with no default
which is somewhat more informative.
> > 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.
> >
Maybe a better thing to say would be:
"The documented value of 'subscripts' does not hold when
using an extended formula (with terms separated by '+')."
which while entirely useless, is completely accurate and at least
wouldn't give you anything to complain about. Would you prefer that?
In any case, you can always do something like
panel = function(x, y, subscripts, ...) {
print(subscripts) ## debug
},
R is a programming language after all, and if you are not prepared to
use it as such, may be you shouldn't be writing complicated panel
functions.
-Deepayan
> > 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
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list