2016-07-30 9 views
0

学校のプロジェクトに光沢のあるアプリを用意する必要があります。 これは、あなたがあなたが見るアプリを見ればあなたはそれらがすべて選択されているアプリを開くが、中に medals.Whenという名前のチェックボックスがありチェックボックスが光沢のあるアプリで選択されていません

https://yuvaln.shinyapps.io/olympics/

のように見えることになっているもののリンクありユーザがそれらをすべてオフにすることを決定した場合、小さなエラーがあり、グラフを描画する必要はありません。

私は私のアプリ ですべてのボックスのチェックを外したときに、私は、トラブルこれに取得が生じています、それは空の図面を描く

これは、コードの重要な部分である:

fluidRow(
    column(3,checkboxGroupInput("Medals", label = strong("Medals"), 
    choices = list("Total" = "TOTAL", "Gold" = 'GOLD', 
    "Silver" = 'SILVER','Bronze'='BRONZE'), 
    selected = c('TOTAL','GOLD','SILVER','BRONZE')))), 

    fluidRow(
    mainPanel(plotOutput('coolplot'),width = '40%')) 
)  
) 
    server <- function(input, output){output$coolplot<-renderPlot(plot.medals2(input$country, 
    input$Startingyear,input$Endingyear,input$Medals))} 
    shinyApp(ui = ui, server = server) 

私が使用していますメダルのベクトルを取得し、開始年、終了年、国を取得し、グラフの図を返す関数plot.medals2。

+0

おそらく 'plot.medals2'を追加すると役に立ちます。また、空の描画はどういう意味ですか?軸は見えますが、線も空白もありませんか? – Dambo

+0

私は軸がプロットタイトルの空白の灰色のスペースではありません – idf4floor

+0

'plot.medals2'を追加すると助けになると思います。 – Dambo

答えて

0

完全なコードを投稿していないため、Irisデータセットを使用した例を再作成しました。私はあなたの質問に答えて下のコードを推測します...

library(shiny) 
library(ggplot2) 
library(dplyr) 

ui <- shinyUI(fluidPage(

    # Application title 
    titlePanel("Checkbox example"), 
    fluidRow(
      column(3,checkboxGroupInput("example", label = strong("Species"), 
             choices = levels(iris$Species), 
             selected = levels(iris$Species)))), 
    fluidRow(
      mainPanel(plotOutput('coolplot'),width = '40%')) 


)) 



server <- shinyServer(function(input, output) { 

    irisSubset <- reactive({ 
      validate(
        need(input$example != "", 'Please choose at least one feature.') 
      ) 
      filter(iris, Species %in% input$example) 
    }) 

    output$coolplot<-renderPlot({ 
      gg <- ggplot(irisSubset(), aes(x = Species, y = Sepal.Length)) 
      gg <- gg + geom_boxplot() 
      print(gg) 
    }) 

}) 

# Run the application 
shinyApp(ui = ui, server = server) 
関連する問題