Hi,
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)?
Thanks,
Vadim
On 5/7/05, Vadim Ogranovich [EMAIL PROTECTED] 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
Can anyone shed any light on what is going wrong here?
Its based on simplifying some actual code that exists in
model.frame.default. It looks like a bug to me. Thanks.
data(iris)
f.default - function(x, subset, ...) {
subset - eval(substitute(subset), iris, .GlobalEnv)
subset
}
# This one
But then mylist is not a list:
x - new(mylist, x = list(x = 1, y = 2))
x[[1]]
Error in x[[1]] : subscript out of bounds
This is probably solvable by a sprinkle of setIs or setAs spells, but
each time I get into the S4 area I feel walking a mine-field.
All this exercise on my part was to write
**
ATENÇÃO
Esta é uma mensagem automática e não monitorada. Não responda essa mensagem,
pois ela não será lida.
On May 7, 2005, at 2:59 PM, Vadim Ogranovich wrote:
But then mylist is not a list:
x - new(mylist, x = list(x = 1, y = 2))
x[[1]]
Error in x[[1]] : subscript out of bounds
This is probably solvable by a sprinkle of setIs or setAs spells, but
each time I get into the S4 area I feel walking a
Actually I think Simon's approach is a good one. Maybe Simon's
comment was really intended to say that its dangerous
to redefine list operations but it should not be dangerous
to define a subclass of list and override operations that
way. Also since the whole purpose of this is for speed I think
Its probably obvious but just for completeness, I missed the
generic definition in pasting this into my post so I have
added it below:
On 5/7/05, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Can anyone shed any light on what is going wrong here?
Its based on simplifying some actual code that