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))
#