在flexdashboard选项卡中未显示的图

时间:2019-11-06 22:13:59

标签: r r-markdown r-plotly flexdashboard

当渲染flexdashboard时,可打印图表仅显示在第一个选项卡上,而不显示在其余选项卡上。下面的可重现示例将flexdashboard示例用于.tabset。我正在运行R 3.6.1

我过去使用过plotly和tabset,但不确定为什么现在不起作用。

---
title: "Tabset Column"
output: flexdashboard::flex_dashboard
---

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

### Chart 1

```{r}
library(ggplot2)
library(plotly)
library(dplyr)

da <-data.frame(ns=rep(0:1,6), month=factor(1:12), a=letters[1:12])

p <- ggplot(da) +
geom_bar(aes(x=month,y=ns,fill=ns),stat = "identity") +
facet_wrap(~a )+
theme_bw(12) + ylab("CYER") +
scale_fill_viridis_c(option="D",direction = -1) 


p2 <- ggplot(da) +
geom_bar(aes(x=month,y=ns,fill=ns),stat = "identity") +
facet_wrap(~a )+
theme_bw(12) + ylab("CYER") +
scale_fill_viridis_c(option="C",direction = -1) 
```

Column {.tabset}
-------------------------------------

### Chart 2

```{r}
ggplotly(p2)%>%layout(
 margin = list(b = 100, l = 100,r = 150))
```   

### Chart 3

```{r}
ggplotly(p)%>%layout(
 margin = list(b = 100, l = 100,r = 150))
```

0 个答案:

没有答案