gpt4 book ai didi

R Flexdashboard 在单个选项卡上绘制多个图

转载 作者:行者123 更新时间:2023-12-04 13:44:35 25 4
gpt4 key购买 nike

我正在尝试将多个 dygraph 图放在 flexdashboard 的单个选项卡上。我尝试了来自 here 的许多不同选项来自 here

我的 RMD 文件如下所示:

    ---
title: "Project Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
---
# Intro {.sidebar}

# Page 1

## Column 1 {.tabset .tabset-fade data-width=850}

### Site 1

```{r Data, echo=FALSE, fig.height=2}

s <- dygraph(as.xts(df,order.by=df$DateTime), group = "NC") %>%
dyOptions(drawPoints = TRUE, pointSize = 1) %>%
dyAxis("y", label = "Salinity (PSU)", valueRange = c(16, 30)) %>%
dyRangeSelector(height = 20) %>%
dyLegend(width = 400)

t <- dygraph(as.xts(df,order.by=df$DateTime), group = "NC") %>%
dyOptions(drawPoints = TRUE, pointSize = 1) %>%
dyAxis("y", label = "Temperature (°C)", valueRange = c(0, 30)) %>%
dyRangeSelector(height = 20) %>%
dyLegend(show = "follow", width = 400)

dy_graph <- list(s,t)
pt <- htmltools::browsable(htmltools::tagList(dy_graph))
pt

```

我尝试了各种其他组合,但它要么只绘制第一个图,将两个图放在一起,要么将它们挤在一起形成一个很小的空间。我什至尝试使用 4 级 Markdown header (####),但这似乎也没有任何作用。

有什么想法吗?

最佳答案

以下是如何使用 splitLayout 在一个标签集中放置多个数字.我还没有弄清楚如何堆叠,比如 2x2 数字。

---
title: "Project Dashboard"
runtime: shiny
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
---

Page with Tabset {.tabset .tabset-fade}
-------------------------------------

### Two Plots on one Tab

```{r}
library(shiny)
library(flexdashboard)
library(dygraphs)

temperature <- ts(frequency = 12, start = c(1980, 1),
data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5,
25.2, 26.5, 23.3, 18.3, 13.9, 9.6))
rainfall <- ts(frequency = 12, start = c(1980, 1),
data = c(49.9, 71.5, 106.4, 129.2, 144.0, 176.0,
135.6, 148.5, 216.4, 194.1, 95.6, 54.4))

output$p1 <- renderDygraph( dygraph(temperature))
output$p2 <- renderDygraph( dygraph(rainfall))
```

```{r}
splitLayout(cellWidths = c("50%"), dygraphOutput("p1"), dygraphOutput("p2"))
```

### Another Tab

Hello

生产...

enter image description here

关于R Flexdashboard 在单个选项卡上绘制多个图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51127918/

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