我有一个训练有素的模型,该模型使用人格特质预测药物使用情况。即如果您性格外向,那么我们预计去年吸烟的机会为xx%。该模型已加载到Shiny文件中,我可以使其正常工作并输出一定百分比,但是由于某些原因,我想要的输出在Web应用程序中不断重复。
服务器:
output$nicotine <- renderText({
df$GenderMale <- as.factor(ifelse(input$GenderMale == "Male",1,0))
df$Neuroticism <- input$Neuroticism/5
df$Extraversion <- input$Extraversion/5
df$X.Openness.to.experience. <- input$X.Openness.to.experience./5
df$Agreeableness <- input$Agreeableness/5
df$Conscientiousness <- input$Conscientiousness/5
df$Impulsiveness <- input$Impulsiveness/5
df$X.Sensation.seeing. <- input$X.Sensation.seeing./5
result <- predict(shiny_nic, df, type = "response")
result <- round(result*100,0)
paste("Based on our sample and the inputs given, we believe that your risk of having used nicotine at
least once in the past year is", result, "%. The proportion of our sample, which used nicotine
in the last year was 56%.")
UI:
textOutput("nicotine")
我在做什么错?这是“基于我们的示例...”的最后一部分,该部分在Shiny Web应用程序中不断重复。即它把句子输入500次而不是一次。
我搜索了周围,但无济于事。预先谢谢你