首页 > 解决方案 > 在 Rmarkdown 中运行后,绘图未显示在 HTML 文件中

问题描述

当我在 Rmarkdown 中生成绘图时,它显示在 Rstudio 的绘图下,但在我编织它时不包括它。如何在降价中包含情节?

我还选中了“创建独立的 HTML 文档”,并且类似的图不会显示在该独立的 HTML 文档中。

例如,我在 Rmarkdown 文件中运行此代码,但绘图不会留在针织文档中。

boxplot(bwt ~ smoke, data=birthwt,
        xlab = "drivetrain (0 = don't smoke, 1 = smoke)",
        ylab = "birth wt. in g",
        main = "birth weight vs smoking status",
        pch = 20,
        cex = 2,
        col = "darkslategray",
        border = "goldenrod3")

请指教。

标签: htmlrr-markdown

解决方案


It does work in the following small snippet of RMD

---
title: "testing"
author: "akrun"
date: "10/05/2021"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r}
library(MASS)
data(birthwt)
boxplot(bwt ~ smoke, data=birthwt,
        xlab = "drivetrain (0 = don't smoke, 1 = smoke)",
        ylab = "birth wt. in g",
        main = "birth weight vs smoking status",
        pch = 20,
        cex = 2,
        col = "darkslategray",
        border = "goldenrod3")

```

-output

enter image description here


推荐阅读