I am trying to include a simple Shiny app in a Quarto website. The expected output is a string with the score and risk, based on some simple conditions. Instead, the textOutput is not rendered. No error message is returned.
_quarto.yml:
project:
type: website
website:
title: "name"
sidebar:
style: "docked"
search: true
contents:
- index.qmd
- section: "Chapter"
contents:
- app.qmd
format:
html:
theme: cosmo
css: styles.css
toc: true
bibliography: references.bib
editor: visual
index.qmd
# Introduction {.unnumbered}
"A towel, \[The Hitchhiker's Guide to the Galaxy\] says, ..."
app.qmd
---
title: app
format: html
server: shiny
---
```{r}
#| panel: fill
checkboxInput("v1", label = "condition 1", value = F)
checkboxInput("v2", label = "condition 2", value = F)
checkboxInput("v3", label = "condition 3", value = F)
checkboxInput("v4", label = "condition 4", value = F)
textOutput("out")
```
```{r}
#| context: server
output$out <- renderText({
risk_tbl <- data.frame(score = c(0:4),
risk = c("0.6%", "3.6%", "9.8%", "34.8%", "46.2%"))
score <- sum(c(input$v1, input$v2, input$v3, input$v4))
risk <- risk_tbl[risk_tbl$score == score,]$risk
paste("The score is", score, "with a risk of", risk, sep = " ")
})
```
Output after rendering to html:
