2017-02-11 71 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)