Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 使用mfcol时,在同一代码块中完成绘图并开始新建_R_Knitr - Fatal编程技术网

R 使用mfcol时,在同一代码块中完成绘图并开始新建

R 使用mfcol时,在同一代码块中完成绘图并开始新建,r,knitr,R,Knitr,当您使用par的mfcol参数在同一个绘图中有多个图形时,在knitr中是否有一种方法可以完成代码块中的绘图并开始新的绘图。我的代码大致如下 --- title: "Untitled" author: "Not me" date: "October 14, 2017" output: html_document --- ```{r} set.seed(73856421) # Plot random number of graphs par(mfcol = c(2, 2)) for(i in

当您使用
par
mfcol
参数在同一个绘图中有多个图形时,在
knitr
中是否有一种方法可以完成代码块中的绘图并开始新的绘图。我的代码大致如下

---
title: "Untitled"
author: "Not me"
date: "October 14, 2017"
output: html_document
---

```{r}
set.seed(73856421)

# Plot random number of graphs
par(mfcol = c(2, 2))
for(i in 1:sample.int(6, 1)) # not in control of the number of plots here
  plot(rnorm(100))

# <-- want plot here

# ...
# some other code
# ....

# plot new results
plot(1, type = "n", xlim = c(0, 1), ylim = c(0, 1))
text(.5, .5, "should be")
plot(1, type = "n", xlim = c(0, 1), ylim = c(0, 1))
text(.5, .5, "together")
plot(1, type = "n", xlim = c(0, 1), ylim = c(0, 1))
text(.5, .5, "in new")
plot(1, type = "n", xlim = c(0, 1), ylim = c(0, 1))
text(.5, .5, "4x4 plot")
```
---
标题:“无标题”
作者:“不是我”
日期:“2017年10月14日”
输出:html\u文档
---
```{r}
种子集(73856421)
#图的随机数
par(mfcol=c(2,2))
对于(1中的i:sample.int(6,1))#这里不控制绘图的数量
绘图(rnorm(100))
#