What I'm trying to do is based off of one checkbox input with 7 different options, create a reactive glm
model based on which checkboxes the user has selected.
In my UI I have the following:
checkboxGroupInput("varChooser", label = h3("Variables to include in model:"),
choices = list("Gender", "Resident", "Citizen", "Pell", "Walk.In", "GPA","Ethnicity"),
selected = list("Gender", "Resident", "Citizen", "Pell", "Walk.In", "GPA","Ethnicity"))
and in my SERVER I have the following:
studyModel <- reactive({
glm(as.formula(paste("Status ~ ",paste0(input$varChooser,collapse="+"))), data=studyData, family = binomial)
})
newStudent <- reactive({
data.frame(
"Gender" = as.numeric(input$Gender),
"Resident" = as.numeric(input$Resident),
"Citizen" = as.numeric(input$Citizen),
"Pell" = as.numeric(input$Pell),
"Walk.In" = as.numeric(input$Walk.In),
"GPA" = as.numeric(input$GPA),
"Ethnicity" = as.numeric(input$Ethnicity)
)
})
goVal <- reactive({
predict(studyModel, newStudent(), type="response")
})
The newStudent
dataframe works well, along with the reactive goVal
, but I am trying to add the dynamic model instead of having one model.
The error I am getting is:
Error: no applicable method for 'predict' applied to an object of class "c('reactiveExpr', 'reactive')"
我想通了-我的predict
函数中没有studyModel
之后的括号
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.