1
```{r scatterplots, collapse=TRUE, results= 'hold'}
p1 <- ggplot(x, aes(y=f.ecdf, x=P2))+geom_point()+theme_bw()
p2 <- ggplot(x, aes(y=f.ecdf, x=P2))+geom_point()+theme_bw()
p3 <- ggplot(x, aes(y=f.ecdf, x=G1))+geom_point()+theme_bw()
p4 <- ggplot(x, aes(y=f.ecdf, x=G2))+geom_point()+theme_bw()
p5 <- ggplot(x, aes(y=f.ecdf, x=P2))+geom_point()+theme_bw()
p6 <- ggplot(x, aes(y=f.ecdf, x=P2))+geom_point()+theme_bw()
p7 <- ggplot(x, aes(y=f.ecdf, x=G1))+geom_point()+theme_bw()
p8 <- ggplot(x, aes(y=f.ecdf, x=G2))+geom_point()+theme_bw()

grid.arrange(
  p1, p2, p3, p4,
  ncol = 2
)

 grid.arrange(
   p5, p6, p7, p8,
   ncol = 2
)
```

但在预览中,代码块在拆分后被评估。

我怎样才能阻止这种情况发生。基本上,我希望所有的情节都被打断。

我还可以提供哪些其他信息来诊断此问题?

在此处输入图像描述

4

1 回答 1

0

看起来有一个 R 笔记本忽略块选项的已知问题:https ://github.com/rstudio/rmarkdown/issues/1077 ,所以不确定是否有一个简单的解决方案 atm。

一个临时修复,可能并不理想,但您可以使用大括号,例如

---
title: "R Notebook"
output: 
  html_notebook
---

```{r scatterplots, collapse=TRUE, results= 'hold'}
library(ggplot2)
library(gridExtra)
set.seed(12345)
x <- data.frame(f.ecdf=rnorm(10), P2=rnorm(10), G1=rnorm(10), G2=rnorm(10))

p1 <- ggplot(x, aes(y=f.ecdf, x=P2))+geom_point()+theme_bw()
p2 <- ggplot(x, aes(y=f.ecdf, x=P2))+geom_point()+theme_bw()
p3 <- ggplot(x, aes(y=f.ecdf, x=G1))+geom_point()+theme_bw()
p4 <- ggplot(x, aes(y=f.ecdf, x=G2))+geom_point()+theme_bw()
p5 <- ggplot(x, aes(y=f.ecdf, x=P2))+geom_point()+theme_bw()
p6 <- ggplot(x, aes(y=f.ecdf, x=P2))+geom_point()+theme_bw()
p7 <- ggplot(x, aes(y=f.ecdf, x=G1))+geom_point()+theme_bw()
p8 <- ggplot(x, aes(y=f.ecdf, x=G2))+geom_point()+theme_bw()

{grid.arrange(
  p1, p2, p3, p4,
  ncol = 2
)

grid.arrange(
  p5, p6, p7, p8,
  ncol = 2
)}

截屏

于 2018-07-31T05:35:07.417 回答