【发布时间】:2019-12-26 15:53:46
【问题描述】:
这是我用来获取用户输入的代码:
library(shiny)
ui<-fluidPage(
textInput(inputId = "name",label = "Enter Name",value="abc"),
radioButtons(inputId = "gender",
label = "Select your gender",
choices = c("Female","Male","Other"),selected = NULL),
checkboxGroupInput(inputId = "hobbies",
label = "select your hobbies",
choices=c("reading","singing","coding","sports")),
selectInput(inputId = "exam",label = "Select exam",
choices=c("MHCET","HSC","SSC")),
numericInput(inputId="marks",label="Enter Marks",value=60),
selectInput(inputId = "stream",label = "Select stream",
choices=c("CE","EXTC","MECH","IT","PPT")),
dateInput(inputId = "dob",label = "Select DOB",
value = NULL,min=NULL,max=NULL,format="dd-mm-yyyy",
startview = "month",weekstart = NULL,language = "en",width = NULL),
actionButton(inputId = "submit",label = "Submit"),
)
server <- function(input, output, session) {
observeEvent(input$submit,{
print(as.table(input$name,input$gender,input$hobbies,input$exam,input$marks,input$stream,input$dob))
})
}
shinyApp(ui=ui, server=server)
我需要找到一种方法以表格的形式显示输出。我尝试使用 file 函数来获取输入,但它不允许获取不同类型的输入。
我也尝试使用 print as.table 函数,但出现事件处理错误。
这个问题应该使用闪亮的库来解决。
【问题讨论】:
-
你检查
shiny::renderTable了吗? -
SO 不适用于在硬件或培训课程中回答问题
-
我确实尝试了 renderTable,但遇到了事件处理错误。