Наблюдение за событием ignoreInit не работает с flexdashboard - PullRequest
0 голосов
/ 25 мая 2020

В Shiny - flexdashboard я использую observeEvent с ignoreInit=TRUE в двух случаях. Один с eventExpr, который является входом напрямую, и другой, где он заключен в eventReactive. Первый observeEvent ниже (соответствует вводу react) ничего не печатает при запуске приложения. Второй (соответствующий вводу input) делает. У обоих есть ignoreInit=TRUE. Есть ли этому объяснение? Я ничего не нашел.

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

```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
```

Column {data-width=350}
-----------------------------------------------------------------------
### A

```{r}

checkboxInput(inputId = "input", label = "input")
checkboxInput(inputId = "react", label = "react")

reactBoxreac = eventReactive(input$react, {input$react})

observeEvent(reactBoxreac(), {
  print("observeEvent of react checkBox is executed\n")
}, ignoreInit=TRUE)

observeEvent(input$input, {
  print("observeEvent of input checkBox is executed\n")
}, ignoreInit=TRUE)

```

1 Ответ

0 голосов
/ 26 мая 2020

Согласно моему комментарию, вам следует избегать имен переменных input

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

```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
```

Column {data-width=350}
-----------------------------------------------------------------------
### A

```{r}

checkboxInput(inputId = "input_data", label = "input")
checkboxInput(inputId = "react", label = "react")

reactBoxreac = eventReactive(input$react, {input$react})

observeEvent(reactBoxreac(), {
  print("observeEvent of react checkBox is executed\n")
}, ignoreInit=TRUE)

observeEvent(input$input_data, {
  print("observeEvent of input checkBox is executed\n")
}, ignoreInit=TRUE)

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