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 中吗?如果是这样,怎么做?我搜索了文档,并且查看了虚拟和超类。我找不到关于将课程合并在一起的任何内容
这是创建类的代码 -
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 是使用债券详细信息的输入计算的 BondTermStructure 是使用债券详细信息和bondcashflows 的输入计算的
我需要将它们全部放入 BondAnalytics 中,这样我才能创建一种输出方法,但我似乎无法正确理解它们是如何变成超类的