我创建了下面的 flexdashboard,我最初在其中创建了四个数据框。然后其中三个数据框显示为图表(dcross2,store,supplier
),一个(dcross1
)显示为表格。
我想要实现的是将所有这四个对象与crosstalk
包连接在一起,当用户点击一个栏时,表格会相应地响应。不是其他图表只有表格。我相信这Abcd
是实现这一目标的关键,因为它在所有数据帧中都很常见,但我不知道如何将所有数据帧连接在一起。
---
title: "Operaitonal dashboard"
author: "Report"
date: 'Date: `r Sys.Date()`'
output:
flexdashboard::flex_dashboard:
orientation: columns
theme: lumen
vertical_layout: scroll
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo=FALSE,
warning= FALSE,
message = FALSE)
library(crosstalk)
library(shiny)
library(plotly)
library(flexdashboard)
library(ggplot2)
library(dplyr)
library(reactable)
##The four dataframes
Abcd<-c("A","A","B","B")
Prod<-c(34,56,56,89)
Div<-c("Ent","Ent","App","High")
dcross1<-data.frame(Abcd,Prod,Div)%>%
SharedData$new()
Counts<-c(45,67,78,56)
dcross2<-data.frame(Div,Abcd,Counts)%>%
SharedData$new()
Store<-c(199,199)
Abcd<-c("A","B")
Oos<-c(500,400)
store<-data.frame(Store,Abcd,Oos)%>%
SharedData$new()
Man<-c("Corp","Adv","Corp","Adv")
Abcd<-c("A","B","A","B")
Counts<-c(45,56,34,78)
Scounts<-c(23,45,67,67)
Per<-c(1,2,3,5)
supplier<-data.frame(Man,Abcd,Counts,Scounts,Per)%>%
SharedData$new()
```
# Out of stock Report {data-icon="fa-cart-arrow-down" data-orientation=rows}
## Row {data-height="200"}
### Out Of Stock: Store Overview {data-width="200"}
```{r Oos Store}
daily_store_oos_gg<-
ggplot(store,
aes(x=Abcd,
y=Oos,
fill=as.factor(Abcd)
)) +
geom_bar(stat="identity", position="dodge")
# Convert to plotly object
daily_store_oos_ply <-
ggplotly(daily_store_oos_gg)
daily_store_oos_ply
```
### Out Of Stock: Division Overview {data-width="200"}
```{r Oos Division}
# Create ggplot object (Aggregated data)
store_division_oos_overview_gg<-
dcross2 %>%
ggplot(aes(x=Div,
y=Counts ,
fill=Abcd,
label = Counts)) +
geom_col(position="fill")
# Create plotly object
store_division_oos_overview_ply<-
ggplotly(store_division_oos_overview_gg)
store_division_oos_overview_ply
```
## Column {data-width=405}
### Supplier Overview Out of Stock
```{r supplier}
# Create ggplot object (Aggregated data)
supplier_oos_overview_gg<-
supplier %>%
ggplot(aes(x=Man ,
y=Scounts
)) +
geom_bar(stat='identity',aes(fill = Abcd)) +
coord_flip()
# Create plotly object
supplier_oos_overview_ply<-
ggplotly(supplier_oos_overview_gg)
supplier_oos_overview_ply
```
### Store Overview Out of Stock
```{r out of stock reactable}
daily_item_oos_rctble<-reactable(
dcross1
)
daily_item_oos_rctble
```