2017-11-08 5 views
0

1-dataframe 2-ggplotのリストを返す関数Identify_IP()があります。私はShinyAppでrenderTableとrenderPlotをする必要があります。このshinyAppコードは、データフレームのみをレンダリングします。しかし、私はプロットを描画することはできません。どんな助け?次serverを使用してShinyAppの複数のオブジェクトのリストからプロットをレンダリングする方法

library(shiny) 

source('InflectionP2.R', local = TRUE) 

runApp(
    list(
    ui = fluidPage(
     titlePanel("Upload your file"), 
     sidebarLayout(
     sidebarPanel(
      fileInput('file1', 'Choose xls file', 
        accept = c(".XLS")), 

      actionButton("btn", "Update Table"), 
      actionButton("btn1", "Display Plot"), 

      downloadButton('downloadData', 'Download') 
     ), 

     mainPanel(
     tableOutput('what'), 
     plotOutput('pl')) 
    ) 
    ) 
    , 

    server = function(input, output, session){ 

     dataOP <- reactive({ 
    inFile <- input$file1 
    if (is.null(input$file1)) 
     return(NULL) 

    Identify_IP(read.table(inFile$datapath)) 
    list(tble = df1, txt = inflection_points, plt = p) 
    }) 


    observeEvent(input$btn, output$what <- renderTable({dataOP()$tble})) 

    observeEvent(input$btn1, output$pl <- renderPlot({ 
    plot(dataOP()$plt) 
    }))    
    } 
    )) 
+0

'dataOP()$ p'をプロットする必要があります。 'plot()'を使用して –

+0

詳細を教えてください。それは私がすでに行ったこととどう違うのですか? – user91

+0

そして、btw、私はdataOP()$ df1を試して、テーブルをレンダリングしなかったので、リストが動作するとは思わない。だから私はdataOP()のために解決しました – user91

答えて

0

は私のために働いていた:私はあなたの関数Identify_IPをコメントアウトし、任意の値で結果を置き換え

server = function(input, output, session){ 

    dataOP <- reactive({ 
     inFile <- input$file1 
     if(is.null(input$file1)){ 
      return(NULL) 
     } 
     #Identify_IP(read.table(inFile$datapath)) 
     list(tble = c(1:20), txt = c(1:10), plt = rnorm(100)) 
    }) 

    observeEvent(input$btn,{ 
     output$what <- renderTable({ 
      dataOP()$tble 
     }) 
    }) 

    observeEvent(input$btn1,{ 
     output$pl <- renderPlot({ 
      plot(dataOP()$plt) 
     }) 
    })    
} 

注意を。 それでも問題が解決しない場合は、おそらくこの関数または関数が返す値に関連している可能性があります。

+0

私はこれが非常に基本的であることを知っています。しかし、どのようにfn()からtble、txt、pltを呼び出すことができますか?それはこれのようなものですか? dfs < - Identify_IP(read.table(inFile $ datapath)) list(tble = dfs $ df1、txt = dfs $ inflection_point、plt = dfs $ p)?私のスキルはこの中では基本的です – user91

+0

'fn()'とは何ですか?反応的な 'dataOP'は' tble'、 'ttxt'、' plt'という名前の要素を持つリストを返します。したがって、 'dataOP()$ plt'を使って' plt'を取り出してください。 –

+0

はい、私の任意の値を 'list(tble = dfs $ df1、txt = dfs $ inflection_point、plt = dfs $ p)'に置き換えなければなりません。 –

関連する問題