我要做的是基于一个带有7个不同选项的复选框输入,根据用户选择的复选框创建一个被动glm
模型。
在我的用户界面中,我有以下内容:
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"))
在我的服务器中我有以下内容:
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")
})
newStudent
数据框与反应goVal
一起运行良好,但我尝试添加动态模型而不是一个模型。
我得到的错误是:
Error: no applicable method for 'predict' applied to an object of class "c('reactiveExpr', 'reactive')"
答案 0 :(得分:0)
我弄明白了 - 我的studyModel
函数中predict
之后我没有括号