首页 > 解决方案 > R中的selectizeInput闪亮

问题描述

我做 R 闪亮的项目,在 ui.RI 有这个代码:

用户界面

    tabPanel("Ctree",  fluidPage(
  sidebarLayout(
    selectizeInput("ctreeinput","Zvolte atributy k cielovemu atributu LoanAmount",choices=colnames(stats_people),multiple=TRUE),
    mainPanel(tableOutput("ctree1"))
    )
 ))

服务器.R

output$ctree1<- renderTable({  
set.seed(123)
library(party)

myFormula = LoanAmount_1 ~ input$ctreeinput

ctree = ctree(myFormula, data=train.ctree)
table(predict(ctree), train.ctree$LoanAmount_1)

ctreePred = predict(ctree, newdata = test.ctree)
table(ctreePred, test.ctree$LoanAmount_1)
})

在 server.RI 中有 myFormula,我想在其中创建如下内容:

myFormula = LoanAmount ~ ApplicantIncome+CoapplicantIncome+Dependents+Gender+Married

...但它必须由用户创建。我想使用选择输入。这个解决方案,我在这里粘贴的,它不起作用,RStudio 说,错误:找不到对象'输入'。我应该怎么做才能处理我的代码?谢谢!

标签: r

解决方案


在 server.R 中,在定义 之前myFormula,您需要定义一个名为 的对象(例如,数据框)input以及一个名为 的子对象(例如,列)ctreeinput


推荐阅读