【问题标题】:R Shiny object of type 'closure' is not subsettable'closure'类型的R Shiny对象不是子集
【发布时间】:2017-02-11 11:59:32
【问题描述】:

我是新来的闪亮。 当我运行这些代码时:

用户界面:

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)

  })
 }
) 

当我运行它时,我得到了错误:

错误:“闭包”类型的对象不是子集

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    在你的情节调用中进行。

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

    【讨论】:

      猜你喜欢
      • 2016-01-14
      • 1970-01-01
      • 1970-01-01
      • 2018-06-22
      • 2015-06-18
      • 1970-01-01
      • 2017-06-01
      • 1970-01-01
      • 2014-08-01
      相关资源
      最近更新 更多