I am creating a quarto/shiny doc that has an echart graphic in it with a simple radio button input widget, but the document isn't rendering with an error that says "! Object 'output' not found".
Below is a reproducible example. Where am I going wrong?
Thanks
---
title: "Test"
format: html
server: shiny
execute:
echo: false
warning: false
---
```{r}
#| label: setup
library(dplyr)
library(echarts4r)
library(shinyWidgets)
library(lubridate)
data("USAccDeaths")
USAccDeaths <- data.frame(as.matrix(USAccDeaths), date=time(USAccDeaths))
USAccDeaths$year <- trunc(USAccDeaths$date)
USAccDeaths$month <- (USAccDeaths$date - USAccDeaths$year) * 12 + 1
colnames(USAccDeaths)[1] <- 'Deaths'
```
```{r}
radioGroupButtons(
inputId = "time_period",
label = "Choices",
choices = c("Month", "Year"),
status = "primary"
)
echarts4rOutput("plot1")
```
```{r}
#| context: server
deaths <- reactive({
USAccDeaths %>%
group_by(tolower(input$time_period)) %>%
summarise('Deaths' = sum(deaths))
})
output$plot1 <- renderEcharts4r({
deaths |>
e_charts(x = tolower(input$time_period)) |> # initialise and set x
e_line(serie = Deaths, smooth = TRUE) |>
e_tooltip(trigger = "axis")
})
```