0
根据单选按钮输入param_type_graph
的值,我尝试显示径向网络或对角线网络(使用软件包networkD3)。我试图在我的renderUI()函数中放入一些if语句,但显然它不起作用。 Shiny App是there。它只适用于径向情况。请使用以下输入测试应用程序:1st input:“petrus”; 第二输入:'WinesAndCo',然后通过点击最后一个蓝色按钮来提交。R Shiny:基于无功值的不同输出类型
UI
ui <- fluidPage(
# Application title
titlePanel("Carrefour Hierarchical Exploration"),
sidebarLayout(
# Sidebar with a slider input
sidebarPanel(
textInput("param_caption", "Rechercher une famille de vin : ", "petrus"),
radioButtons("param_sites", "Choisis sur quel site",
c("Auchan" = "1",
"G.V.P." = "2",
"Lavinia" = "3",
"Millesima" = "4",
"Vinatis"="5",
"WinesAndCo"="6")),
radioButtons("param_typegraph", "Type de Graphique",
c("Radial Network" = "rad",
"Diagonal Network" = "diag"
)),
sliderInput("param_height", "Graph Height:",
min = 300, max = 3000, value = 300
),
sliderInput("param_width", "Graph Width:",
min = 400, max = 4000, value = 400
),
sliderInput("param_size", "Police Size:",
min = 10, max = 60, value = 10
),
actionButton(inputId="param_go",label="Submit",style="color: #fff; background-color: #337ab7; border-color: #2e6da4")
),
# Show a plot of the generated distribution
mainPanel(
uiOutput('mygraph')
)
)
)
服务器
server <- function(input, output) {
# a lot of compution ... that I do not display
# ...
output$graphresdiag <- renderDiagonalNetwork({
diagonalNetwork (tree_to_display(),height = input$param_height,width = input$param_width, fontSize = input$param_size)
})
output$graphresrad <- renderRadialNetwork({
radialNetwork (tree_to_display(),height = input$param_height,width = input$param_width, fontSize = input$param_size)
})
output$mygraph= renderUI({
if (isolate(input$param_typegraph)=="diag")
{diagonalNetworkOutput(outputId = "graphresdiag",
width = paste0(input$param_width,"px"),
height =paste0(input$param_height,"px"))}
if (isolate(input$param_typegraph)=="rad")
{radialNetworkOutput(outputId = "graphresrad",
width = paste0(input$param_width,"px"),
height =paste0(input$param_height,"px"))}
})
}
你会做什么,使其工作?
尝试'conditionalPanel' –
THKS现在看来,这就是我期待已久 –