2016-11-09 12 views
0

以下の光沢のあるアプリを実行すると、最初にエラーinvalid type/length (symbol/0) in vector allocationが表示されます。しかし、「Submit」をクリックすると、アプリケーション機能が意図どおりに機能します。最初のshinyrアプリの負荷でselectInputエラーを修正しました

この起動エラーを回避し、最初から正しく動作させる方法はありますか?

plot_and_summary <- function(dat, col){ 
    summary <- dat %>% summarize_(mean = interp(~mean(x), x = as.name(col)), 
           sd = interp(~sd(x), x = as.name(col))) 
    plot <- ggplot(dat, aes_string(x = col)) + geom_histogram() 
    return(list(summary = summary, plot = plot)) 
} 


library(shiny) 

# Define UI for application that draws a histogram 
ui <- fluidPage(
    titlePanel(""), 
    sidebarLayout(
    sidebarPanel(
     uiOutput("column_select"), 
     submitButton("Submit") 
    ), 
    mainPanel(
     tableOutput("summary"), 
     plotOutput("plot") 
    ) 
) 

) 

# Define server logic required to draw a histogram 
server <- function(input, output){ 
    dat <- reactive({iris}) 


    output$column_select <- renderUI({selectInput("col", label = "select column", choices = as.list(names(dat())))}) 



    pas <- reactive({plot_and_summary(dat(), input$col)}) 
    output$plot <- renderPlot({pas()$plot}) 
    output$summary <- renderTable({pas()$summary}) 


} 


shinyApp(ui = ui, server = server) 

答えて

関連する問題