All, My package is S4 an I would like to strongly type the input to the constructor function. I understand from reading help etc that the call to new should be in a function and the method initialize is only used when one would like to customize the call to new or when the inputs are different from the slots.
I cannot seem to get the method initialize to work. Below is a minimal example. My class works, my getter works, my constructor function works but I cannot get the initialize to strongly type the inputs. Any help to understand this would be greatly appreciated Best, Glenn setClass("TestClass", slots = c( FirstNum = "numeric", SeconNum = "numeric", )) setGeneric("FirstNum", function(object) standardGeneric("FirstNum")) setMethod("FirstNum", signature("TestClass"), function(object){object@FirstNum}) TestClass <- function(data1, data2, data3){ FirstNum = data1 * data2 SeconNum = data1/data2 * data3 new("TestClass", FirstNum = FirstNum, SeconNum = SeconNum) } setMethod("initialize", "TestClass", "Can I use initialize to type the inputs data1, data2, and data3. If the function TestClass does heavy lifting can I use TestClass in the method initialize ? If so, how?" }) ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel