Shiny App中的子集条件

时间:2014-02-05 16:44:08

标签: r shiny subset

我有这段代码:

# 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)),
...

然而,在choices=subset(NestingArea, Sp=='Cc')$Country))我希望Sp等于第一个radioButton上选择的“物种”,因此该列表会因物种而改变。我尝试了类似:Sp==speciesSp=="species"Sp==input.species,但它不起作用。

我在做错什么的任何线索?

1 个答案:

答案 0 :(得分:0)

subset评估意外环境中的一些参数,这些参数有时可能与Shiny期望事物运行的方式不相容。一般的建议是暂时在Shiny应用程序中工作时避免subset

所以我要替换

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

NestingArea[NestingArea$Sp=="Cc", "Country"]