The code below is a reproducible example. When I comment out the step
function, the shiny works well. But when I use step
function, the shiny gives the error "object 'tmp.data' not found"
Does anyone have the idea how to make 'tmp.data' visible to the step
function? Thank you!
indicators <- mtcars[,c(-1,-6)]
input = list(y='mpg')
tmp.model <- function(){
tmp.data = cbind(mtcars[input$y], indicators)
biggest = as.formula(lm(paste(input$y,"~."), tmp.data))
tmp.model = lm(paste(input$y,"~disp"), tmp.data)
tmp.model = step(tmp.model, direction="forward", scope=biggest, k=log(nrow(mtcars))) # tmp.data not found
tmp.model
}
summary(tmp.model())