【发布时间】:2017-06-01 16:05:58
【问题描述】:
我想在我的闪亮应用中显示只有一个情节:如果我动态选择 A,闪亮的应用必须显示 plot(c(1:3)),否则闪亮的应用必须显示 grViz 类对象。
library(shiny)
runApp(list(
ui = fluidPage(
uiOutput("optionsplots"),
uiOutput("plot")),
server = function(input, output) {
output$optionsplots <- renderUI({
selectInput("options", "Options to plot:",choices=c("A","B"))
})
output$plot <- renderUI({
if(input$options == 'A'){renderPlot({plot(c(1:3))})}
else{renderGrViz({grViz("digraph boxes_and_circles {
# a 'graph' statement
graph [overlap = true, fontsize = 10]
# several 'node' statements
node [shape = box,
fontname = Helvetica]
A; B; C; D; E; F
node [shape = circle,
fixedsize = true,
width = 0.9] // sets as circles
1; 2; 3; 4; 5; 6; 7; 8
# several 'edge' statements
A->1 B->2 B->3 B->4 C->A
1->D E->A 2->4 1->5 1->F
E->6 4->6 5->7 6->7 3->8
}")})}
})
}
),launch.browser = T)
错误:“闭包”类型的对象不是子集
一种可能的解决方案是放入 ui.R plotOutput("plot")(用于绘制 plot(c(1:3)))和 grVizOutput("plot2")(用于绘制 grviz 对象),但我不想要它,因为如果我不选择选项“A”(或其他),我闪亮的应用程序中会有一个空白区域。
【问题讨论】: