[Rd] Bug in str or issue with class management in my package?
mtmorgan at fhcrc.org
Fri Mar 23 14:01:04 CET 2007
booteval.relimp has the statement
ausgabe <- calc.relimp(empcov, type = type, diff = diff,
rank = rank, rela = rela, always = always, groups = groups,
groupnames = groupnames)
class(ausgabe) <- "relimplmbooteval"
This changes the name of the class of ausgabe, without changing its
structure. I'm guessing that prior to this call ausgabe did not have a
slot "pmvd.lower". Here's the simpler version:
> setClass("B", contains="A", representation=representation(y="numeric"))
> a <- new("A")
> class(a) <- "B"
Error in FUN(c("y", "x")[[1L]], ...) : no slot of name "y" for this object of class "B"
and some behavior which is somehow weird:
> slot(a, "y")
Error in slot(a, "y") : no slot of name "y" for this object of class "B"
> slot(a, "y") <- 10 # 'creates' the slot!
> slot(a, "y")
Probably what you want to do is to create a 'setAs' method
<your code here, e.g.,>
ausgabe <- as(ausgabe, "relimplmbooteval")
I'm not really sure what <your code here> should look like; my first
obj <- new("relimplmbooteval")
slots <- slotNames(from)
for (slt in slots)
slot(obj, slt) <- slot(from, slt)
which would not be very memory efficient (each slot assignment copies
the entire object) but is perhaps fine for your needs.
Hope that helps
Ulrike Grömping <groemp at tfh-berlin.de> writes:
> Dear developeRs,
> with R 2.4.1 (and also 2.4.0), the function str() fails on objects of class
> relimplmbooteval, if there are unused slots, which is very often the case. I
> am not sure whether this is a bug in str() or a correct behavior of str()
> that unmasks some sloppiness in my usage of S4 classes (that I am not aware
> Reproducible example (package relaimpo needed):
> The program
> yields the error message
> Errorr in FUN(c("lmg.lower", "lmg.upper", "lmg.rank.lower",
> "lmg.rank.upper", :
> no slot named "pmvd.lower" for this object of class
> (back-translated from German).
> Regards, Ulrike
> View this message in context: http://www.nabble.com/Bug-in-str-or-issue-with-class-management-in-my-package--tf3453429.html#a9633559
> Sent from the R devel mailing list archive at Nabble.com.
> R-devel at r-project.org mailing list
Bioconductor / Computational Biology
More information about the R-devel