I create the flexdashboard below in which I initially create four dataframes. Then three of these dataframes are displayed as charts(dcross2,store,supplier
) and one (dcross1
) as table.
What I want to achieve is to connect all of these four objects together with crosstalk
package in a way thet when the user clicks on a bar the table will respond accordingly. Not the other charts only the table. I believe that Abcd
is the key to achieve this since it is common in all dataframes but I do not know how to connect all of them together.
---
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
```