I want to get a table output using selectInput
function. I have to import(not upload) different csv files in place of object error1,2,3,4 but when I am doing this I am not getting proper output in mainPanel
. Please help me in importing csv files in right place so that I could get table as an output in mainpanel.
library(shiny)
ui <- shinyUI( fluidPage(
titlePanel(h3("PUMA", style = "color:black")),
sidebarLayout(
sidebarPanel(
tags$head(
tags$style("body{backgroud-color: pink;}")),
selectInput("mydata", "ERROR MESSAGE:",
choices = c("Clamping lever closing not detected-Error number 7 / 31"="error1",
"Filter paper wrong or not inserted-Error number 30 / 20"="error2",
"Device is heating up (working temp. not reached yet) Heating Option-Error number 32 / 51"="error3",
"Door is open (Timeout key)-Error number 15 / 100"="error4")
)
),
mainPanel(tabsetPanel(
tabPanel(h2("TABLE", style = "color:red"), verbatimTextOutput ("mydata")),
#tabPanel(h2("ERROR", style = "color:red"), verbatimTextOutput("ERROR")),
tags$head(tags$style("#mydata{color:blue;
font-size: 17px;
font-style: bold
}"))
),
width = 12)
)))
server <- shinyServer(function(input, output){
output$mydata <-renderPrint ({
input$mydata
})
})
shinyApp(ui = ui, server = server)
Your render
function actually returns the selected item as a string from your input
and not the object itself. You can wrap all the objects in a list
or use get
:
Option 1
# put all objects in a list
mDat <- list(error1 = cars, error2 = airquality, error3 = chickwts, error4 = co2)
server <- shinyServer(function(input, output){
output$mydata <- renderPrint ({
mDat[[input$mydata]]
})
})
Option 2
# This assumes that you have the objects error1, ..., error4 in the environment
server <- shinyServer(function(input, output){
output$mydata <- renderPrint ({
get(input$mydata)
})
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.