Error when developing a shiny app with quarto

I am trying to develop a shiny app for Species locations. Here is a reproducible example with the New Zeland data from the spData package.

After running the quarto document I got the following message:

Error: nz does not contain data

---
title: "New Zeland"
format: 
  html:
    page-layout: custom
server: shiny
---

```{r}
#| context: setup
#| mesaage: false
#| warning: false
library(shiny)
library(rmarkdown)
library(tidyverse)
library(rio)
library(sf)
library(mapview)
library(leaflet)
library(spData)
#| context: setup
nz |>
  st_transform(4326)
#| panel: sidebar
selectInput("nz", label = "Region", choices = unique(nz$Island))
#| panel: fill
leafletOutput('plot1', height = "80vh")
#| context: server

nzInput <- reactive({
  nz[nz$Island == input$Island, ]
})

output$plot1 <- renderLeaflet({
  nz <- nzInput()
  m <- mapview(nz)
  m@map
})

this should probably be input$nz because of the definition you had earlier that selectInput("nz",

Thank you very much. That was the problem.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.