2017-02-11 73 views
0

我是新來的閃亮。 當我運行這些代碼:R類型'閉包'的閃亮對象不可子集

UI:

library(shiny) 

shinyUI(pageWithSidebar(
    headerPanel("Hi"), 
    sidebarPanel(selectInput('variable','parameter:',list('mipigi'='mpg',"cylender"='cyl',"displacement"='disp',"horsepower"='hp')) 
), 

    mainPanel(
    h3(textOutput("caption")), 
    plotOutput("histo") 

    ) 
)) 

服務器:

library(shiny) 
library(datasets) 

shinyServer(function(input,output){ 
formulaText <- reactive({ 
paste("qsec~", input$variable) 
}) 
output$caption <- renderText({ 
formulaText() 
}) 
output$histo<-renderPlot({ 
plot(as.formula(formulaText),mtcars) 

    }) 
} 
) 

當我運行它,我得到了錯誤:

錯誤:類型的對象「關閉'是不可子集的

回答

0

在你的情節調用使它。

plot(as.formula(formulaText()),mtcars)