'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
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
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
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
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
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
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] &
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)
; 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
'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
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
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
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
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
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
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
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
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
18 matches
Mail list logo