【发布时间】:2015-05-05 00:54:55
【问题描述】:
最小可重现示例:
#### global.R
combinations <- data.frame(animal = c(rep('cat', 2),
rep('dog', 3),
rep('horse', 2)),
color = c('blue',
'black',
'red',
'red',
'black',
'red',
'green'),
region = c('west',
'west',
'east',
'west',
'east',
'west',
'east'))
基本上,我想在闪亮的应用程序上提供一个 UI 选项,以首先选择您的动物,然后弹出一个“颜色”下拉菜单,仅使用所选动物的可能值。那么应该会弹出一个“区域”下拉菜单,并且仅包含基于其他两个可接受的值。
我做了一个非常基本的版本,但在如何嵌套时遇到了麻烦。
#### ui.R
library(shiny)
shinyUI(fluidPage(
# Sidebar with dropdown for animal
sidebarLayout(
sidebarPanel(
selectInput("animal",
label = "Choose your animal:",
choices = unique(combinations$animal)) ,
wellPanel(uiOutput("ui_1")),
)
)
))
有没有办法避免手动输入所有可能的组合并将其包装在“uiOutput”调用中?我使用的真实文件有大约 1200 种可能的组合。
【问题讨论】: