0

To explain the issue, I created the simple app you see below. I have no problem using the mtcars dataset directly, but when the issue is reactive (or master in the example), I get the could not find function "master" error. No matter what I tried, I couldn't overcome this issue, so I'm asking for your assistance.

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    verbatimTextOutput("txt1"),
    verbatimTextOutput("txt2")
  )
)

server <- function(input, output) {
  
  master <- reactive({
    mtcars
  })
  
  model1 <- reactive({
    olsrr::ols_step_both_p(lm(hp~.,data = mtcars))
  })
  
  model2 <- reactive({
    olsrr::ols_step_both_p(lm(hp~.,data = master()))
  })
  
  output$txt1 <- renderPrint({
    summary(model1()$model)
  })
  
  output$txt2 <- renderPrint({
    summary(model2()$model)
  })
  
}

shinyApp(ui, server)

enter image description here

Thanks in advance.

youraz
  • 463
  • 4
  • 14

1 Answers1

0

I don't know much about shiny, but it seems that you didn't define master as a function. So when you call master() inside model2, it doesn't know what you mean.

You could either define it as a funcion, possiblysomething like:

master <- reactive({
  function(){mtcars}
})

Or calling master as an object:

model2 <- reactive({
  olsrr::ols_step_both_p(lm(hp~.,data = master))
})