【发布时间】:2022-01-04 19:47:18
【问题描述】:
我在选择特定列时遇到问题,具体取决于 selectInput。我试图使混淆矩阵。我有论点(数据=结果)但现在我需要参考=? ,这是 data_t_add 的一个特定列。该列(必须是参考)必须是 data_t_add 的 input$choose_y。我该怎么做 ?谢谢。
服务器:
output$choose_y <- renderUI({
y_choices <- names(data())
selectInput('choose_y', label = 'Choose Target Variable', choices = y_choices)
})
output$choose_x <- renderUI({
x_choices <- names(data())[!names(data()) %in% input$choose_y]
checkboxGroupInput('choose_x', label = 'Choose Predictors', choices = x_choices)
})
observeEvent(input$c50, {
form <- paste(isolate(input$choose_y), '~', paste(isolate(input$choose_x), collapse = '+'))
c50_fit <- eval(parse(text = sprintf("ctree(%s, data = data())", form)))
output$tree_summary <- renderPrint(summary(c50_fit))
output$tree_plot_c50 <- renderPlot({
plot(c50_fit)
})
result <- predict(c50_fit, newdata = data_t())
data_t_add = cbind(data_t(), result)
output$data_t_add_out <- renderTable({
return(head(data_t_add))
})
tbl = confusionMatrix(result, REFERENCE, mode = "prec_recall")
output$conf_matrix <- renderPrint({ tbl })
})
##################### EDIT of SERVER
try = data_t_add %>% select(input$choose_y)
output$tripple <- renderPrint({
return(str(try))
})
output$tripples <- renderPrint({
return(str(data_t_add))
})
tbl = confusionMatrix(result, try, mode = "prec_recall")
output$conf_matrix <- renderPrint({ tbl })
【问题讨论】:
标签: r shiny shinydashboard shiny-server shiny-reactivity