【问题标题】:using textInput in Shiny flexdashboard在 Shiny flexdashboard 中使用 textInput
【发布时间】:2021-04-26 03:44:34
【问题描述】:

新年快乐。 我正在尝试使用闪亮的多元线性回归应用程序。 我在 lm() 公式中使用 textInput 作为自变量部分,如下所示:

textInput("multiLinearReg","R Formula for features for multiple linear regression:")

mlg = eventReactive(input$goP4,{
  data = Train_Test()
  dataM = data['Train']$Train
  dataM = as.data.frame(dataM)
  target = dataM$Sale_Price
  
  model1 = lm(target ~ input$multiLinearReg,data=dataM)
  result = list("Summary"=summary(model1),"Confidence Interval"=confint(model1,level=input$confInt))
  result
})

renderPrint({
 mlg()
})

但我一直收到这个error variable lengths differ (found for 'input$multiLinearReg')

我不知道如何解决它。 非常感谢任何帮助

【问题讨论】:

  • 因为错误表明问题出在lm(target ~ input$multiLinearReg,data=dataM),打印input$multiLinearReg 是什么
  • 所以当我在文本字段中右键 MS_SubClass 时,我使用 renderPrint({input$multiLinearReg}) 时得到 [1] "MS_SubClass"

标签: r shiny flexdashboard


【解决方案1】:

我实际上找到了一个适合我的解决方案,如下所示:

mlg = eventReactive(input$goP4,{
  data = Train_Test()
  dataM = data['Train']$Train
  dataM = as.data.frame(dataM)
  target = 'Sale_Price'
  feature = eval(expression(input$multiLinearReg))[[1]]
  formula = as.formula(paste(target,'~',feature))
  model1 = lm(formula,data=dataM)
  result = list("Summary"=summary(model1),"Confidence Interval"=confint(model1,level=input$confInt))
  result
})

renderPrint({
 mlg()
})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-07
    • 2020-04-03
    • 2017-10-16
    • 2020-04-26
    • 2017-07-10
    • 2020-12-09
    • 2023-04-02
    • 2018-01-18
    相关资源
    最近更新 更多