在 R-Markdown 中仅可视化相关图

问题描述 投票:0回答:1

下面的代码用于使用

corrplot
包可视化相关矩阵。

目标只是展示情节。但是,在输出为 docx 的 R-Markdown 文件上。下面的代码显示了绘图和相关值。 (见附图)。

如何运行此代码以便在文档中仅生成绘图?

ti.corr.plot <- corrplot(cor(ti.pilot.numeric, use="complete.obs"), order = "hclust", tl.col='black', tl.cex=.75, method = "circle")
ti.corr.plot 

enter image description here

r r-markdown correlation
1个回答
0
投票

尝试通过下拉菜单“新文件”在 r studio 中打开一个新的

.rmd
文件。你会得到一个很好的例子。这一点很关键:

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

在您的示例中,这意味着:

---
title: "Untitled"
output: word_document
date: "2024-05-14"
---

```{r code, echo=FALSE}
ti.corr.plot <- corrplot(cor(ti.pilot.numeric, use="complete.obs"), order = "hclust", tl.col='black', tl.cex=.75, method = "circle")
ti.corr.plot 
```
© www.soinside.com 2019 - 2024. All rights reserved.