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
})