问题描述:

I have this code:

# Sidebar to select the species

sidebarPanel(

radioButtons("species", "Species:",

list("Caretta caretta"="Cc",

"Chelonia mydas"="Cm")),

# Sidebar to select the country (conditional of the species)

radioButtons("country_type", "Choose:",

list("list", "coordinates")),

conditionalPanel(

condition="input.country_type=='list'",

selectInput("country", "Country:",

choices=subset(NestingArea, Sp=='Cc')$Country)),

...

However, at choices=subset(NestingArea, Sp=='Cc')$Country)) I would like that the Sp would be equal to the "species" chosen on the first radioButton, so that the list would change in consequence of the species. I have tried somethng like: Sp==species , Sp=="species" and Sp==input.species , but it doesn't work.

Any clue of what I am doing wrong?

网友答案:

subset evaluates some of the arguments in unexpected environments which can, at times, be incompatible with how Shiny expects things to be run. The general advice is to avoid subset when working in Shiny apps for now.

So I'd replace

subset(NestingArea, Sp=='Cc')$Country

with

NestingArea[NestingArea$Sp=="Cc", "Country"]
相关阅读:
Top