Есть ли способ сделать и TableGrob, и ggplot реактивными в примере вывода - PullRequest
0 голосов
/ 22 октября 2019

У меня есть кое-какие разъяснения. У меня есть 2 кадра данных. Я заполнил tablegrob из 1 данных и ggplot из других данных. Но есть ли способ заставить их реагировать. Например, у меня есть фильтр имен (Mill-A, Mill-B и т. Д.). Так что в соответствии с этим выбором мне нужно иметь таблицу и ggplot на вкладке Performance. Я пытался сделать это, но, к сожалению, этого не произошло, поэтому я прошу помощи в этом сообществе здесь. Пожалуйста, помогите мне исправить код здесь. Пример кода прилагается

---
title: "Untitled"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    theme: cosmo
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(ggplot2)
library(shiny)
library(RGraphics)
library(gridExtra) 
```
```{r}
Performance1 <- structure(list(Mills = c("Mill-A", "Mill-B", "Mill-C", "Mill-D", 
"Mill-E"), Performance = c(0.5, 0.4, 0.2, 0.9, 0.4)), row.names = c(NA, 
-5L), class = "data.frame")
Past_Maintainence <- structure(list(Mill = c("Mill-A", "Mill-B"), `Electrical Maintainence done` = structure(c(1569283200, 
1569369600), class = c("POSIXct", "POSIXt"), tzone = "UTC"), 
    `Instrumentation Maintainence done` = structure(c(1569369600, 
    1569456000), class = c("POSIXct", "POSIXt"), tzone = "UTC"), 
    `Mechanical Maintainence done` = structure(c(1569456000, 
    1569283200), class = c("POSIXct", "POSIXt"), tzone = "UTC")), row.names = c(NA, 
-2L), class = "data.frame")
```
Summary
=================

Inputs {.sidebar}
-----------------------------------------------------------------------
```{r}
    selectInput("Mill1","Equipment",choices = c("All","Mill-A","Mill-B","Mill-C","Mill-D","Mill-E"),selected = "All",multiple = TRUE)
```

Column {data-width=300}
-----------------------------------------------------------------------

### Performance {data-width=10}

```{r}
output$t31 <- renderPlot({
  if (input$Mill1 != "All"){
    pd1 <- Past_Maintainence %>% filter(Mill %in% input$Mill)
  }
  if (input$Mill1 != "All"){
  tableGrob(pd1,theme = ttheme_default(base_size = 8))
    }
  })
output$g34 <- renderPlot({
  if (input$Mill != "All") {
    pd <- Performance1 %>% filter(Mills %in% input$Mill)}
  if (input$Mill != "All") {
     ggplot(data = pd,aes(x=Mills,y=Performance, fill=Performance))+geom_bar(stat = "identity",width = 0.5)+theme(plot.margin = unit(c(1,1,1,1),"cm"))+theme(axis.title.x = element_blank())+theme(axis.title.y = element_blank())+theme(legend.position = "none")+theme(axis.text.x = element_text(angle = 0,vjust = 1,size = 5))+theme(axis.text.y = element_text(angle = 0,vjust = 1,size = 5))
  }
  })
grid_layout <- rbind(c(1, 2))

output$filter_71 <- renderUI(
  if (input$Mill1 != "All") {
  plotOutput("t31")
  plotOutput("g34")  
  })
uiOutput("filter_71")
```
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...