【发布时间】:2017-07-09 07:27:20
【问题描述】:
我正在构建一个闪亮的网络应用程序,该应用程序从用户那里获取输入值,例如姓名和性别。我想将这些值转换为数据框,但我收到 “错误:无法将类“c("shiny.render.function", "function")" 强制转换为 data.frame" 错误。
这是我在 server.R 文件中的内容:
nText<- eventReactive(input$click_counter, valueExpr = {
a<- renderText(input$name)
b<- renderText(input$gender)
c<- renderText(input$college)
d<- renderText(input$team)
e<- renderText(input$score)
return(data.frame(player=a,college=b,gender=c,team=d,score=e))
})
output$nText<- renderDataTable({
nText()
})
这就是我在 ui.R 文件中的内容:
actionButton("click_counter","Submit"),
dataTableOutput("nText")
【问题讨论】:
-
你到底在想什么是a、b、c、d或e的结构?您是否意识到您不能拥有带有语言元素的数据框列?也许您应该使用列表?
-
只是不要用
renderText()包装所有inputs