gpt4 book ai didi

r - 更改rmarkdown保存由r代码生成的图像的位置

转载 作者:行者123 更新时间:2023-12-04 16:52:01 26 4
gpt4 key购买 nike

我有一个rmarkdown文档,正在将该文件转换为md文档。
我的问题是我希望将由情节创建的图片放在文件同一目录中的名为Images的文件夹中。

假设我有这个文件:

---
title: "my test"
author: "daniel"
date: "18/08/2015"
output:
md_document
---

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r}
summary(cars)
```

You can also embed plots, for example:

```{r, echo=FALSE}
plot(cars)
```

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


渲染时我有这个:

This is an R Markdown document. Markdown is a simple formatting syntax
for authoring HTML, PDF, and MS Word documents. For more details on
using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that
includes both content as well as the output of any embedded R code
chunks within the document. You can embed an R code chunk like this:

summary(cars)

## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00

You can also embed plots, for example:

![](test_files/figure-markdown_strict/unnamed-chunk-2-1.png)

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


我想要那条线

![](test_files/figure-markdown_strict/unnamed-chunk-2-1.png)


是这样的:

![](images/unnamed-chunk-2-1.png)


并将图像放置在那里。

最佳答案

就像是:

---
title: "my test"
author: "daniel"
date: "18/08/2015"
output:
md_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r opts, echo = FALSE}
knitr::opts_chunk$set(
fig.path = "images/"
)
```


将所有生成的图形保存到 images子目录(如果该目录不存在,则创建该目录)。

关于r - 更改rmarkdown保存由r代码生成的图像的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32083106/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com