[Rd] listof

Michael Friendly friendly at yorku.ca
Sun Aug 3 23:15:51 CEST 2014

An interesting topic, but I'll only respond with my own experience,
and that is, while 'listof' could be usefully extended there was not
enough meat on the bones to want to do so. I think this is a limitation
of the S3 class/method structure, as I see it.

In several packages (effects, heplots, candisc, vcdExtra) I/we
deal with lists of objects of a given class, and want to define
methods for plot(), summary(), print(), etc.  In these cases, the
simplest solution was to designate a new class, e.g., 'efflist'
for a list of effects in a univariate lm/glm/polr/ ... model
or 'candiscList' for a list of candisc objects.  Methods for the
*list class could then use an apply() construct over the list

Most recently,
in the effects package, we implemented some effects plot methods
for multivariate linear models. This is essentially a two-way collection
of effects for terms x responses, but how to represent this in the
class structure to re-use the existing code for a single effect
of a given response variable?

The solution used here was to define a new class, 'mlm.efflist', with 
new methods for this class.  This works within the current S3 class
scheme, but doesn't provide an extendible semantics.


On 7/29/2014 11:20 PM, Adrian Baddeley wrote:
> Dear R developers
> A question about the class 'listof',  defined in package 'stats'.
> Other than its definition and use in the code for 'anova',
> we can't see that the class 'listof' is used for anything else
> (in recommended packages, or elsewhere).
> In the spatstat package we have been using a 'listof'
> to represent a list of spatial objects of the same class
> (such as point patterns, or pixel images)
> and we've defined a plot method.
> Is it OK for us to hijack an existing class in this way,
> or is this a violation of some future plans/ design feature of R ?
> We're about to publish a book on spatstat
> so I would much appreciate advice if we need to change it.
> regards
> Adrian
> Prof Adrian Baddeley FAA
> University of Western Australia

More information about the R-devel mailing list