Построение ошибки реактивных данных: «объект типа« замыкание »не является подмножеством» - PullRequest
0 голосов
/ 26 июня 2019

В моем приложении Shiny я хочу дать пользователю возможность удалять данные. Несмотря на просмотр нескольких вопросов по этой теме, я не могу найти решение.

data("swiss")
swiss2 <- swiss
rownames_swiss2 <- rownames(swiss2)

ui <- fluidPage(
           sidebarLayout(
             sidebarPanel(
               checkboxGroupInput(inputId = "var_4_linearModel", label = "Choose a variable", 
                                            choices = names(swiss2[c(1,2,3,5,6)]), width = '100%', selected = "Fertility"), 
               verbatimTextOutput(outputId = "summary_linearModel", placeholder = TRUE), 
               selectInput(inputId="selectedLeveragePoints", label = "select leverage points", 
                           choices=rownames(swiss2), multiple = TRUE),
               checkboxInput(inputId="adjustedModel", label = "view adjusted model", value = FALSE)
             ),

             mainPanel(
             verbatimTextOutput(outputId = "model")
             ) 
           )

)

server <- function(input, output) {

  # get selected variables 
  variables <- reactive({ paste(input$var_4_linearModel, sep = " " , collapse = '+') })

  #build model without selected points 
#Error is probably somewhere here
  leveragePoints <- reactive({ input$selectedLeveragePoints })
  swissNoLeverage <- reactive({ swiss2[-which(rownames_swiss2 %in% leveragePoints() ),] })
  noLeverageFormula <- reactive({  paste("swissNoLeverage$Education  ~ ", variables()) })
  noLeverageLinearModel <- reactive( {lm(noLeverageFormula(), data = swissNoLeverage()) })

  # output model
  testModel <-  reactive( 
    if(!is.null(input$var_4_linearModel) && !is.null(input$selectedLeveragePoints) && (input$adjustedModel == TRUE)){
      return(noLeverageLinearModel() )
    } else {
      print("select your model ")
    })

  output$model <- renderPrint({ summary(testModel())  })
}

shinyApp(ui=ui, server = server)

Я ожидал, что смогу удалить точки данных, но получаю сообщение об ошибке «объект типа« замыкание »не является поднабором»

Приветствия и заранее спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...