Re: [Rd] understanding virtual classes and extensions thereof

2006-10-21 Thread Parlamis Franklin
't have > any slots defined, use setClassUnion() for "mom", with the other > classes members of the union. > > The other versions are mainly to be back-compatible, with > "Programming with Data" in particular. They _should_ produce the > same resu

[Rd] understanding virtual classes and extensions thereof

2006-10-20 Thread Parlamis Franklin
I am having some trouble creating a hierarchy of virtual classes (akin to the class structure in the 'Matrix' package). I think they arise from my not understanding the best way to specify virtual subclasses of a virtual class. please see questions below code. setClass("mom") setClass("ki

[Rd] default arguments in generics and methods

2006-10-19 Thread Parlamis Franklin
i believe the following is true but would appreciate confirmation that it is intended behavior and will continue: if a default argument is employed in the definition of a generic function, and the generic is called with the argument in question (call it 'ARG') missing, then the method for si

[Rd] dispatching on group generics with more than one formal

2006-10-10 Thread Parlamis Franklin
please see the code below. foo2 fails to dispatch correctly, but foo does fine. i have tried 'cacheMetaData(1)' and a number of different variants of 'cacheGenericsMetaData', on the possibility there is a caching issue. but i still can't sort it out. also one general question: does it rea

[Rd] class unions?

2006-10-06 Thread Parlamis Franklin
the code below has me confused: setClassUnion("index", c("numeric", "character", "logical")) extends("numeric") # i don't see the class union library(Matrix) extends("numeric") # now i see the class union i am aware that the "Matrix" package separately defines the

[Rd] potential setClass bug (with user-defined environment)

2006-09-27 Thread Parlamis Franklin
the following returns an error in an 'exists' call on my machine MyEnv <- new.env() setClass("Numeric", "numeric", where=MyEnv) franklin parlamis > version _ platform powerpc-apple-darwin8.7.0 arch powerpc os darwin8.7.0 system powerpc, darwin

Re: [Rd] generics for primitive functions

2006-09-23 Thread Parlamis Franklin
dates. Not what happens in your first example though. > > If you really want a "numeric" class that does something different > for sqrt(), define an S4 class that contains "numeric" > > setClass("WeirdNumber", contains="numeric") > [1] &

[Rd] generics for primitive functions

2006-09-22 Thread Parlamis Franklin
i think these two code snippets exhibit a bug. they are identical but for the inclusion of an initial line in snippet [2] [1] setMethod("Math", signature(x = "numeric"), function(x) "Works") getGeneric("sqrt")(4) [2] getGeneric("sqrt")(4) setMethod("Math", signature(x = "numeric"), function(x)

Re: [Rd] validity testing as part of '@<-'

2006-09-22 Thread Parlamis Franklin
; lot of my code produces these creatures). > > > On 9/21/06, Duncan Murdoch <[EMAIL PROTECTED]> wrote: >> On 9/21/2006 5:29 PM, Parlamis Franklin wrote: >> > 'methods' package feature request / discussion starter: >> > >> > perhaps a call to 'v

[Rd] validity testing as part of '@<-'

2006-09-21 Thread Parlamis Franklin
'methods' package feature request / discussion starter: perhaps a call to 'validObject' should occur at part of any slot replacement operation (and the operation not be carried out if it would invalidate the object)? this may prevent the need for prophylactic 'validObject' calls in other us

[Rd] residual '*tmp*' variable after "[<-" error

2006-09-20 Thread Parlamis Franklin
self-sanity check prior to filing a bug report: attempted replacement that generates an error leaves a '*tmp*' variable in the global environment. test <- 1:10 test[2:4] <- expression(e) ls() i've read section 3.4.4 of the "R Language Definition" which discusses the mechanism for replacement

[Rd] attributes of S4 objects

2006-09-13 Thread Parlamis Franklin
I am having a bit of a struggle deciding when to use attributes with S4 objects. Clearly the 'class' attribute will always be present. But it is not clear to me whether the architects of the methods package intend that other attributes, such as 'names', will still be used when the S4 impl

Re: [Rd] setMethod("Summary")

2006-09-04 Thread Parlamis Franklin
i believe, if the function you are trying to work with has "..." as the first formal argument (as do most if not all of the "Summary" group functions), you will need to redefine the generic in order to provide a "real" S4 argument on which to dispatch. the following works for me (IIRC it was

Re: [Rd] S4 methods for "+"

2006-08-25 Thread Parlamis Franklin
If you plan to do this for certain (non-primitive) "Math" and "Math2" group functions you will also need setGeneric calls of this form: setGeneric("log", group="Math") This much is documented in the "group generic" doc page. What is undocumented (AFAIK), and tripped me up for a while before

Re: [Rd] S3 fonctions for object of S4 class

2006-08-23 Thread Parlamis Franklin
Franck: I suspect you'll have to include the exact wording of the relevant setGeneric and setMethod calls (as well as any other functions called in your method) to get an answer to your question. I just did: > setGeneric("start", function(x, ...) standardGeneric("start")) [1] "start" > set

[Rd] @ accesses attributes, not just formal slots ?

2006-05-11 Thread Parlamis Franklin
Using the '@' operator, I am able to extract a 'names' attribute assigned to a formal object. However, I can not use the replacement form ('@<-') to assign that attribute. > setClass("foo", representation("numeric")) [1] "foo" > (new("foo", 1:4)->a) An object of class “foo” [1] 1 2 3 4 > na

[Rd] expression objects

2006-05-01 Thread Parlamis Franklin
if 'e' is a vector of mode 'expression', will the following always return TRUE: identical(e, parse(text = as.character(e))) ? > (e <- expression(x, y, z, 200*f%/%d, sin(e))) expression(x, y, z, 200 * f%/%d, sin(e)) > identical(e, parse(text = as.character(e))) [1] TRUE i have been relying o

[Rd] methods for @ operator

2006-05-01 Thread Parlamis Franklin
i often find myself having a list of similarly-classed S4 objects and needing a list containing a particular extracted slot from those objects. so i did the following: > setMethod("slot", signature(object = "list"), + function(object, name) + lapply(object, function(i) sl