我做R闪亮项目,在ui.R中,我有以下代码:
ui.R
tabPanel("Ctree", fluidPage(
sidebarLayout(
selectizeInput("ctreeinput","Zvolte atributy k cielovemu atributu LoanAmount",choices=colnames(stats_people),multiple=TRUE),
mainPanel(tableOutput("ctree1"))
)
))
server.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.R中,我有myFormula,我想在其中创建如下内容:
myFormula = LoanAmount ~ ApplicantIncome+CoapplicantIncome+Dependents+Gender+Married
...,但必须由用户创建。我想使用selectizeInput。 RStudio说,此解决方案(我在此处粘贴的内容)不起作用,该错误是:未找到对象“输入”。我应该怎么做才能处理我的代码?谢谢!
答案 0 :(得分:0)
在server.R中,在定义myFormula
之前,需要定义一个名为input
的对象(例如,数据框)以及一个名为{{1 }}。