On Sat, 7 May 2005, Vadim Ogranovich wrote:

I tried to write the dim method for the list class, but R doesn't seem
to dispatch to it:
dim.list = function(x) c(length(x[[1]]), length(x))
dim(list(1))
NULL
dim.list(list(1))
[1] 1 1

What is the correct way of registering dim.list with .Primitive("dim")?

You really don't want to be doing this: the standard dim() function is intended to work with lists and is used e.g. for matrix lists.
So you are in danger of breaking things.


For that reason and for performance reasons, the internal dispatch only works on explicit class attributes as given by oldClass(), not the implicit ones given by class().


-- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595

______________________________________________
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to