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)
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
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, darwin8.7.0
, WeirdNumber, function(x) Weird)
[1] Math
xx = new(WeirdNumber, 1:10)
sqrt(xx)
[1] Weird
Parlamis Franklin wrote:
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
'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
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
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 Martin, I
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
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
names(a) -
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)
12 matches
Mail list logo