2017-05-06 10 views
0

私はチェックボックス "グラフ"をクリックするとグラフが表示されない理由を知りたいのですが(次のコード)以下はコードの例です。また、renderUIの代わりにconditionalPanelを使って同じことをすることが可能かどうかを知りたいでしょうか?私は私がoutput$plot1 <- renderPlot({ブラケットの下に何が起こるかを見て取り始めるでしょう条件付きプロットshinydashboard

library(shinydashboard) 
library(shiny) 
library(plotly) 
library(ggplot2) 


# Can set box height from environment var 

useboxheight <- Sys.getenv("USE_BOX_HEIGHT") 

if (tolower(useboxheight) == "true") { 

    row1height <- 300 

    row2height <- 240 

    row3height <- 110 

} else { 

    row1height <- row2height <- row3height <- NULL 

} 

body <- dashboardBody(

    fluidRow(

    box(

     title = "Box title", 

     status = "primary", 

     plotOutput("plot1", height = 240), 

     height = row1height 

    ), 

    uiOutput("ui") 

), 



    # Boxes with solid headers 

    fluidRow(

    box(

     title = "Title 1", width = 4, solidHeader = TRUE, status = "primary", 

     height = row2height, 

     sliderInput("orders", "Orders", min = 1, max = 500, value = 120), 

     radioButtons("fill", "Fill", inline = TRUE, 

        c(None = "none", Blue = "blue", Black = "black", red = "red") 

    ) 

    ), 

    box(

     title = "Title 2", 

     width = 4, solidHeader = TRUE, 

     height = row2height 

    ), 

    box(

     title = "Title 3", 

     width = 4, solidHeader = TRUE, status = "warning", 

     height = row2height, 

     selectInput("spread", "Spread", 

        choices = c("0%" = 0, "20%" = 20, "40%" = 40, "60%" = 60, "80%" = 80, "100%" = 100), 

        selected = "60" 

    ) 

    ) 

), 

    # Solid backgrounds 

    fluidRow(

    box(

     width = 4, 

     height = row3height, 

     background = "black", 

     "A box with a solid black background" 

    ), 

    box(

     title = "Title 5", 

     width = 4, 

     height = row3height, 

     background = "light-blue", 

     "A box with a solid light-blue background" 

    ), 

    box(

     title = "Title 6", 

     width = 4, 

     height = row3height, 

     background = "maroon", 

     "A box with a solid maroon background" 

    ) 



) 

) 



ui <- dashboardPage(

    dashboardHeader(title = "Row layout"), 

    dashboardSidebar(checkboxGroupInput(inputId="Graph", label = h4("Graph print"), 
             choices = list("graph" = "graph"),selected = NULL)), 

    body 

) 



server <- function(input, output) { 



    set.seed(122) 

    histdata <- rnorm(500) 



    output$plot1 <- renderPlot({ 

    if (is.null(input$orders) || is.null(input$fill)) 

     return() 



    data <- histdata[seq(1, input$orders)] 

    color <- input$fill 

    if (color == "none") 

     color <- NULL 

    hist(data, col = color) 

    }) 


    output$ui <- renderUI({ 

    check1 <- input$Graph == "graph" 

    if(length(check1)==0){check1 <- F} 

    if(check1){ 
     box(

     status = "warning", 

     plotOutput("plot1", height = 240), 

     height = row1height 
    ) 
    } 
    else{return(NULL)} 
    }) 


} 


shinyApp(ui, server) 

乾杯

デイブ

答えて

0

。条件関数が健全であることを確認してください。

あなたのrenderUIコードと同じです。