R S4 initialize and callNextMethod() -
i trying figure out, why code below throws error:
error in .local(.object, ...) : argument "data" missing, no default
problem code:
setclass("a", representation(a="numeric"), "virtual") setclass("b", representation(b="numeric"), contains="a") setmethod("initialize", "a", function(.object, data){ .object@a <- data[1] }) setmethod("initialize", "b", function(.object, data){ .object@b <- data[2] callnextmethod() }) data <- 1:2 new("b", data)
thank help!
maybe looking for?
setclass("a", representation(a="numeric"), "virtual") setclass("b", representation(b="numeric"), contains="a") setmethod("initialize", "a", function(.object, data){ .object@a <- data[1] .object }) setmethod("initialize", "b", function(.object, data){ .object@b <- data[2] .object <- callnextmethod(.object, data) .object }) data <- 1:2 new("b", data)
Comments
Post a Comment