当前位置: 动力学知识库 > 问答 > 编程问答 >

r - Subset conditions in a Shiny App

问题描述:

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"]
分享给朋友:
您可能感兴趣的文章:
随机阅读: