Re: [R] How can I write methods for 'as()'?

2011-06-15 Thread Jamie Olson
Since nobody else has respond, I thought I'd take a stab. Maybe if I'm wrong enough somebody will correct me, but my understanding is that that kind of situation, ie the pain of getting the correct method called when there is a dependency on the type of more than one argument is part of the motiva

Re: [R] How can I write methods for 'as()'?

2011-06-06 Thread Janko Thyson
Okay, I found something that is working, but it looks and feels pretty awkward as the method def and method lookup takes place in one function ;-) setRefClass("A", fields=list(X="numeric")) setRefClass("B", contains="A", fields=list(Y="character")) mySetAs <- function( from, to ){

Re: [R] How can I write methods for 'as()'?

2011-06-06 Thread Janko Thyson
Somehow I don't see my own postings in the list, so sorry for replying to my own message and not the one that went out to the list. I got a little further and I think I found exactly the thing that is bothering me: how to get "extended" method dispatch going in 'setAs()': setRefClass("A", field

[R] How can I write methods for 'as()'?

2011-06-06 Thread Janko Thyson
Dear list, I wonder how to write methods for the function 'as' in the sense that I can call 'as(object, Class, strict=TRUE, ext)' and let method dispatch figure out the correct method. AFAIU, there is a difference between, e.g. 'as.data.frame' and the methods of 'as()' as stated above since th