Можем ли мы иметь таблицу, отображаемую без применения каких-либо входов - PullRequest
0 голосов
/ 04 февраля 2020

ниже приведен код представления. Код в порядке, но на самом деле, как только я открываю приложение, мне нужно отображать только 2 строки таблицы радужной оболочки (как это должно быть обязательно без каких-либо фильтров и кнопки отправки). затем по кнопке фильтра и отправки должна отображаться таблица. мы можем достичь этого?

---
title: "Untitled"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(dplyr)
library(DT)
library(shinycssloaders)
library(DT)
library(rhandsontable)
library(shinyjs)
library(dplyr)
library(shiny)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
selectInput("Tic","",choices = c("","ALL",as.character(iris$Species)),selected = NULL)
actionButton("Submit","Submit")
textOutput("Total")
tableOutput("SUMMARY_GENERAL_table")


  data1 <- eventReactive(input$Submit,{
  if(input$Tic == "ALL"){
  table_display  <- iris
  }

  else {
  table_display <- iris %>% filter(Species %in% input$Tic)
  }
})


output$SUMMARY_GENERAL_table <- renderTable(
                data1()
  )


output$Total <- renderText(
  paste0("Sum ",formatC(as.numeric(sum(data1()[(data1()$Species == "setosa"),]$Sepal.Width))))
)

```

1 Ответ

0 голосов
/ 04 февраля 2020

Это должно работать: сначала я определяю data1, но без необходимости нажимать «Отправить». Затем я подробно опишу два выражения для таблицы: одно, когда «Отправить» не нажимается, и одно, когда «Отправить».

---
title: "Untitled"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
  orientation: columns
vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(dplyr)
library(DT)
library(shinycssloaders)
library(DT)
library(rhandsontable)
library(shinyjs)
library(dplyr)
library(shiny)
```

Column {data-width=650}
-----------------------------------------------------------------------

  ### Chart A

```{r}
selectInput("Tic","",choices = c("","ALL",as.character(iris$Species)),selected = NULL)
actionButton("Submit","Submit")
textOutput("Total")
tableOutput("SUMMARY_GENERAL_table")

data1 <- reactive({

  if (input$Tic != "ALL"){
    table_display <- iris %>% filter(Species %in% input$Tic)
  }
  else{
    table_display  <- iris
  }

})

output$SUMMARY_GENERAL_table <- renderTable({
  iris
})

observeEvent(input$Submit, {
  output$SUMMARY_GENERAL_table <- renderTable({
    data1()
  })
})


output$Total <- renderText(
  paste0("Sum ",formatC(as.numeric(sum(data1()[(data1()$Species == "setosa"),]$Sepal.Width))))
)

```
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...