2016-07-30 54 views
0

我需要为学校项目准备一个闪亮的应用。 这是什么是应该看起来像未在闪亮应用中选中复选框

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

如果你看你看有一个名为复选框medals.When你 打开他们都选择了应用程序,但在应用的链接事件用户决定取消选中它们应该有一个小错误,并且不应该绘制图表。

我有麻烦到这一点,当我取消所有的箱子在我的应用程序 它绘制了一个空的绘图

这是代码的重要组成部分:

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) 
相关问题