Lógica reactiva condicional brillante basado en flexdashboard
Estoy tratando de hacer contiditonalmente cualquiera de los dos tipos de render (renderPlot
) u otro (renderText
) basado en alguna entrada. Esto es lo que probé:
---
title: "Citation Extraction"
output:
flexdashboard::flex_dashboard:
vertical_layout: scroll
orientation: rows
social: menu
source_code: embed
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
```
Sidebar {.sidebar}
=====================================
```{r}
textInput("txt", "What's up?:")
```
Page 1
=====================================
### Chart A
```{r}
urtxt <- reactive({input$txt})
if (nchar(urtxt()) > 20){
renderPlot({plot(1:10, 1:10)})
} else {
renderPrint({
urtxt()
})
}
```
Pero dice:
Así que traté de agregar un reactivo alrededor del condicional que resulta en devolver la funciónreactive
devoluciones.
reactive({
if (nchar(urtxt()) > 20){
renderPlot({plot(1:10, 1:10)})
} else {
renderPrint({
urtxt()
})
}
})
¿Cómo puedo tener una lógica reactiva condicional?