0
嘿我是新來的R和有一個小問題插入圖形表示R中
我有以下的數據集,由12個不同的債券:
dput(Synthetic_bond_creation)
structure(list(`Days to maturity` = c(1419, 202, 1565, 1182,
2080, 1036, 811, 2436, 1296, 609, 1792, 986), `Yield to maturity` = c(2.699,
0.487, 4.019, 1.421, 2.394, 1.366, 1.107, 2.717, 1.592, 0.988,
2.151, 2.278)), .Names = c("Days to maturity", "Yield to maturity"
), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-12L))
到目前爲止,我得到如下:
library(readxl)
Synthetic_bond_creation <- read_excel("~/UZH/Bachelorarbeit/Synthetic bond
creation.xlsx")
View(Synthetic_bond_creation)
plot(Synthetic_bond_creation$`Days to maturity`,
Synthetic_bond_creation$`Yield to maturity`, xlab = "Days to maturity", ylab
= "Yield to maturity in %", main = "Bonds of 'Societe Generale SA' on
13.03.2013")
abline(lm (Synthetic_bond_creation$`Yield to maturity` ~
Synthetic_bond_creation$`Days to maturity`))
現在我想要構建一個合成的5年期債券,這意味着我需要在x = 1300的迴歸線上獲得到期日以及相應y值的值。
我想「畫」我的字的目標看起來如下:
虛線應該是黑色的。
請使用'dput(Synthetic_bond_creation)',而不是'打印(Synthetic_bond_creation)' – Pop
好吧,我編輯它 – rbonac