How can I stop by code blocks from splitting in preview of R Notebook?
How can I stop by code blocks from splitting in preview of R Notebook?
```{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
)
```
But in preview the code chunks are being evaluated after splitting.
How can I stop this from happening. Basically, I want all plots to flow interrupted.
What other information can I provide to diagnose this?
1 Answer
1
Looks like there's a known issue of R notebooks ignoring chunk options: https://github.com/rstudio/rmarkdown/issues/1077, so not sure if there's a straightforward solution atm.
One ad hoc fix, probably not ideal, but you can use curly brackets e.g.
---
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
)}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.