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对象的变量。我不知道该软件甚至可以在这里发布。通过合并我的意思是说我有一个拥有命名插槽的超类,并且还从另外两个类继承。该软件运行其他功能并为其他类(不是超类)生成结果。所以,我认为这些类必须足够聪明才能插入正确的超类插槽。现在,我不这么认为,看起来他们必须一次一个分配一个 –