>>>>> Paul Bailey <pdbai...@umd.edu> >>>>> on Thu, 27 Jan 2011 23:51:21 -0500 writes:
> Hi, I'm trying to make a new S4 object with a slot for a > "link-glm" object. R doesn't like me have a slot of class > "link-glm" >> class(make.link("probit")) > [1] "link-glm" >> setClass("a",representation(item="link-glm")) > [1] "a" Warning message: undefined slot classes in > definition of "a": item(class "link-glm") you need a setOldClass("link-glm") before the the setClass() above and then things "work". > setOldClass("link-glm") > setClass("a",representation(item="link-glm")) [1] "a" > fa <- function() { new("a",item=make.link("probit")) } > b <- fa() > b An object of class "a" Slot "item": $linkfun function (mu) .... .... Martin Maechler, ETH Zurich >> fa <- function() { > + new("a",item=make.link("probit")) + }> >> fa() > Error in validObject(.Object) : invalid class "a" object: > undefined class for slot "item" ("link-glm") > # and a link-glm looks like a list to me, so I thought I > would tell R it is a list and see what happens >> setClass("b",representation(item="list")) > [1] "b" >> fb <- function() { > + new("b",item=make.link("probit")) + } >> fb() > Error in validObject(.Object) : invalid class "b" object: > invalid object for slot "item" in class "b": got class > "link-glm", should be or extend class "list" > Any advice? > Regards, Paul Bailey Ph.D. candidate Department of > Economics University of Maryland > ###### raw code ##### > setClass("a",representation(item="link-glm")) fa <- > function() { new("a",item=make.link("probit")) } fa() > setClass("b",representation(item="list")) fb <- function() > { new("b",item=make.link("probit")) } fb() > ########### > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel