如何在带有运行时闪亮的rmarkdown html_notebook中使用renderPlot布局2行,然后是1列

Jas*_*lns 6 r r-markdown shiny rnotebook

考虑以下rmarkdown html_notebook示例:

---
output: html_notebook
runtime: shiny
---

```{r}
library(ggplot2)
library(shiny)

blank1 <- renderPlot({ ggplot() + labs(title = "Plot 1") })
blank2 <- renderPlot({ ggplot() + labs(title = "Plot 2") })
blank3 <- renderPlot({ ggplot() + labs(title = "Plot 3") })

column(6, blank1, blank2)
column(6, blank3)
```
Run Code Online (Sandbox Code Playgroud)

我想将地块显示为:

情节布局

我尝试了一些事情,包括:

fluidRow(
  column(6, blank1, blank2),
  column(6, blank3)
)
Run Code Online (Sandbox Code Playgroud)

但是我无法Plot 3跨越多行。


附加说明(每个注释):

  • 我欢迎cowplotpatchwork解决方案,但我需要从shiny(例如ggplot(aes(x = input$var_select)) + ...
  • 理想情况下,我想利用column()和/或fluidRow()保留响应式设计方面。

Jas*_*lns 4

我能够通过renderPlot显式传递高度来解决这个问题。我对其他解决方案仍然很感兴趣:

blank1 <- renderPlot({ ggplot() + labs(title = "Plot 1") }, height = 200)
blank2 <- renderPlot({ ggplot() + labs(title = "Plot 2") }, height = 200)
blank3 <- renderPlot({ ggplot() + labs(title = "Plot 3") }, height = 400)

fluidRow(
  column(6, fluidRow(blank1), fluidRow(blank2)),
  column(6, fluidRow(blank3))
)
Run Code Online (Sandbox Code Playgroud)

从响应式设计方法来看,它并不完美,但它会起作用。

地块高度闪亮