Example of the problem - class.a has slots 1, 2, 3
and inherits from class c (4, and 5).
The slots in class (1, 2, 3) are passed to function.b as variables.
the output of function b is as class.c. So now I have the following.
class.a
slot 1 a value
slot 2 a value
slot 3 a value
slot 4 empty
slot 5 empty
class.c
slot 4 a result
slot 5 a result
可以將class.c簡單地合併到class.a中嗎?如果是這樣,怎麼樣?我搜查了文檔和 我看了一個虛擬和超類。 我不能合併一起上課操作S4類
這裏找到什麼是創建類的代碼 - 利用債券細節 BondTermStructure使用債券輸入項計算輸入的計算存儲信息 BondCashFlows
setClass("BondDetails",
representation(
Cusip = "character",
ID = "character",
BondType = "character",
Coupon = "numeric",
IssueDate = "character",
DatedDate = "character",
StartDate = "character",
Maturity = "character",
LastPmtDate = "character",
NextPmtDate = "character",
Moody = "character",
SP = "character",
BondLab = "character",
Frequency = "numeric",
BondBasis = "character",
Callable = "character",
Putable = "character",
SinkingFund = "character"))
setClass("BondCashFlows",
representation(
Price = "numeric",
Acrrued = "numeric",
YieldToMaturity = "numeric",
ModDuration = "numeric",
Convexity = "numeric",
Period = "numeric",
PmtDate = "Date",
TimePeriod = "numeric",
PrincipalOutstanding = "numeric",
CouponPmt = "numeric",
TotalCashFlow = "numeric"))
setClass("BondTermStructure",
representation(
EffDuration = "numeric",
EffConvexity = "numeric",
KeyRateTenor = "numeric",
KeyRateDuration = "numeric",
KeyRateConvexity = "numeric"))
setClass("BondAnalytics",
contains = c("BondDetails","BondCashFlows", "BondTermStructure"))
BondDetails細節和bondcashflows
我需要把它們都納入BondAnalytics,所以我可以創建一個輸出的方法,我只是 似乎無法得到它的權利這些如何變成了超類
您可以重寫函數b來獲取類a的對象,將結果分配給插槽4和5,然後再次返回對象? –
可以將類設置爲「繼承」,但我沒有看到關於「合併」意味着能夠回答此問題的充分解釋概念。代碼....我們需要代碼。 –
約有700行代碼覆蓋了三個函數,它們傳遞來自S4對象的變量。我不知道該軟件甚至可以在這裏發佈。通過合併我的意思是說我有一個擁有命名插槽的超類,並且還從另外兩個類繼承。該軟件運行其他功能併爲其他類(不是超類)生成結果。所以,我認爲這些類必須足夠聰明才能插入正確的超類插槽。現在,我不這麼認爲,看起來他們必須一次一個分配一個 –