gpt4 book ai didi

r - 如何在一个面板中包含 renderPrint() 和其他渲染

转载 作者:行者123 更新时间:2023-12-01 22:47:57 35 4
gpt4 key购买 nike

我有以下 Shiny-Rmarkdown 应用:

---
title: "My First Shiny"
runtime: shiny
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
---


```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(d3heatmap)
library(ggplot2)
```


Rows {data-height=800}
-----------------------------------------------------------------------

### Plot1

Here is the attempt


```{r}
# x <- datasets::iris[,-5] # [c(2:4,7),1:4]
checkboxInput("cluster", "Apply clustering")

renderD3heatmap(
d3heatmap(mtcars,
dendrogram = if (input$cluster) "both" else "none",
scale="none",
xaxis_height = 170,
yaxis_width = 170,
height=200,
cexRow = 1.0,
cexCol = 1.0,
k_row = 6,
k_col = 6
)

)

renderPrint({tibble::as.tibble(mtcars)})

```

***

Some commentary about Frame 2.

### Plot2

它生成以下应用:

enter image description here

请注意,虽然我有这一行:

renderPrint({tibble::as.tibble(mtcars)})

它不显示在 Plot1 面板的底部。正确的做法是什么?

最佳答案

renderD3heatmap没有outputArgs renderPlot 使用的通过widthheight plotOutput 的参数,所以我认为你不能那样做。

相反,您可能想使用 orientation: columns并创建 2 列,然后将其拆分:

---
title: "My First Shiny"
runtime: shiny
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
---


```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(d3heatmap)
library(ggplot2)
```

Column
-----------------------------------------------------------------------

### Plot1

Here is the attempt


```{r}
checkboxInput("cluster", "Apply clustering")
renderD3heatmap(
d3heatmap(mtcars,
dendrogram = if (input$cluster) "both" else "none",
scale="none",
xaxis_height = 170,
yaxis_width = 170,
height=200,
cexRow = 1.0,
cexCol = 1.0,
k_row = 6,
k_col = 6
))
```

### Data

```{r}
renderPrint({tibble::as_tibble(mtcars)})
```

***

Some commentary about Frame 2.

Column
-----------------------------------------------------------------------

### Plot2

enter image description here

关于r - 如何在一个面板中包含 renderPrint() 和其他渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44792090/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com