2016-09-19 1 views
0

selectInput機能を使用してテーブル出力を取得します。 オブジェクトerror1,2,3,4の代わりに異なるcsvファイルをインポートする必要があります(アップロードしないでください)。これを行うときに、mainPanelに適切な出力が得られません。適切な場所にcsvファイルをインポートするのを手伝って、メインパネルの出力としてテーブルを取得できるようにしてください。selectInput関数を使用してR shiny appの出力としてテーブルまたはデータフレームを取得するにはどうすればよいですか?

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) 
+0

あなたが望むものを正確にわかりません。あなたの期待される出力は? csvをアップロードするには、[this](http://shiny.rstudio.com/gallery/file-upload.html)を試してみてください。 – Jimbou

+0

error1にはデータフレームがあり、そのデータフレームを出力します。たとえば、サイドバーパネルから「クランプレバーが検出されない - エラー番号7/31」を選択した場合、メインパネルの出力としてオブジェクトerror1に格納されているデータフレームを取得する必要があります。 –

答えて

0

あなたrender機能は、実際にあなたのinputはなく、オブジェクト自体からの文字列として選択した項目を返します。あなたはlist内のすべてのオブジェクトをラップするかgetを使用することができます。

オプション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]] 
    })  
}) 

オプション2

# This assumes that you have the objects error1, ..., error4 in the environment 

server <- shinyServer(function(input, output){ 
    output$mydata <- renderPrint ({ 
     get(input$mydata) 
    })  
}) 
関連する問題