[R] Creating S4 class with a slot as an array
Glenn Schultz
glennmschultz at me.com
Tue Oct 20 16:35:39 CEST 2015
Hello All,
I am trying to create an S4 class with a slot that is an array. Below is the code I tried but I have missed something. Any suggestions are appreciated.
setClass("CashFlow",
representation(
CashFlowArray = "array"))
setMethod("initialize",
signature = "CashFlow",
function(.Object,
CashFlowArray = "array"
){
.Object at CashFlowArray
return(.Object)
callNextMethod(.Object,...)
})
CashFlow <-function(CashFlowArray = array()){
new("CashFlow",
CashFlowArray = CashFlowArray)
}
CFTest <- array(data = 2, c(360,8))
Test <- CashFlow(CashFlowArray = CFTest)
Thanks,
Glenn
More information about the R-help
mailing list