R减价-数字显示在部分的底部,而不是显示在我放置文本的文本之间

bmp9r5qi  于 2023-01-18  发布在  其他
关注(0)|答案(1)|浏览(102)

我在R markdown中有下面的代码块,它们生成2个图,中间有一些文本,但pdf输出只是将所有图发送到文档的底部。我如何才能使图停留在文本的位置,我希望它在哪里?

---
title: "Evaluation of Income annuities with money-back guarantees"
author: "Long Life Insurance Company's Actuarial Team"
output:
  word_document:
    toc: yes
  pdf_document:
    fig_width: 6
    fig_height: 3.5
    fig_caption: yes
    fig_crop: no
    toc: yes
    number_sections: yes
---

[Text]

{r, echo=FALSE, include=TRUE, messages=FALSE, warnings=FALSE, fig.cap = "EPVs at different ages and interest rates"}

    plot(xAges,EPVs[1,],ylim=c(min(EPVs),max(EPVs)),main="EPV of CRIA",xlab=
       "Annuitant's age",ylab="EPV",pch=1,cex=0.5,col=2)
    legend(60,30, legend=c("r = 2%", "r = 4%","r = 6%", "r = 8%"),col=2:5, pch=c(1,3,8,16), cex=1)

[Text]

{r, echo=FALSE, messages=FALSE, warnings=FALSE,fig.cap = "EPVs at different given interest        rates"}
 
    plot(IntRates65,EPVs[1,],ylim=c(min(EPVs),max(EPVs)),main="EPV of all 3 products",xlab=
       "Interest rate",ylab="EPV",pch=1,cex=0.8,col=2)
    legend(0.08, 16, legend=c("LOIA", "IRIA","CRIA"),col=2:4, pch=c(1,3,8), cex=0.8)

[Text]

尝试上面的代码,但它将所有图发送到底部

mftmpeh8

mftmpeh81#

我认为只要把每一个数字放在它自己的块中,在开头和结尾加上“”,就可以了,就像这样

---
title: "Evaluation of Income annuities with money-back guarantees"
author: "Long Life Insurance Company's Actuarial Team"
output:
  word_document:
    toc: yes
  pdf_document:
    fig_width: 6
    fig_height: 3.5
    fig_caption: yes
    fig_crop: no
    toc: yes
    number_sections: yes
---

[Text]

```{r, echo=FALSE, include=TRUE, messages=FALSE, warnings=FALSE, fig.cap = "EPVs at different ages and interest rates"}

    barplot(c(2,5))

[Text]

 
    barplot(c(2,5), main="Main title",
        xlab="X axis title",
        ylab="Y axis title",
        sub="Sub-title")

[Text]

相关问题