[Rd] help with S4 objects: trying to use a "link-glm" as a class in an object definition
Paul Bailey
pdbailey at umd.edu
Fri Jan 28 05:51:21 CET 2011
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")
> 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()
###########
More information about the R-devel
mailing list