2017-01-04 3 views
0

私はプロットを表示したり、データフレームを印刷することができるシャイニーのアプリを持っています。それは両方を行いますが、データフレームの最初の10行だけを出力し、 "... 86個の行"を追加します。少なくとも40行のデータフレームを表示したいと思います。 &ヘッド(a、n = 50)の両方を試しましたが、合計で10行しか表示されません。どうすればより多くの行を表示させることができますか?シャイニー:データフレームには10行しか表示されません

あなたの出力はただのdata.frameになるだろうとされていない知っている場合にはこれは私が

server.R

output$IPLMatch2TeamsPlot <- renderPlot({ 
    printOrPlotIPLMatch2Teams(input, output) 

}) 

# Analyze and display IPL Match table 
output$IPLMatch2TeamsPrint <- renderPrint({ 
    a <- printOrPlotIPLMatch2Teams(input, output) 
    head(a,n=50) 
    #a 
}) 
output$plotOrPrintIPLMatch2teams <- renderUI({ 
    # Check if output is a dataframe. If so, print 
    if(is.data.frame(scorecard <- printOrPlotIPLMatch2Teams(input, output))){ 
     verbatimTextOutput("IPLMatch2TeamsPrint") 
    } 
    else{ #Else plot 
     plotOutput("IPLMatch2TeamsPlot") 
    } 

}) 

ui.R

tabPanel("Head to head", 
         headerPanel('Head-to-head between 2 IPL teams'), 
         sidebarPanel(
          selectInput('matches2TeamFunc', 'Select function', IPLMatches2TeamsFuncs), 
          selectInput('match2', 'Select matches', IPLMatches2Teams,selectize=FALSE, size=20),         
          uiOutput("selectTeam2"), 
          radioButtons("plotOrTable1", label = h4("Plot or table"), 
             choices = c("Plot" = 1, "Table" = 2), 
             selected = 1,inline=T) 


         ), 
         mainPanel(
          uiOutput("plotOrPrintIPLMatch2teams") 

         ) 

答えて

1

持っているものですテキストのランダムなビットで、表形式のデータを表示するために最適化された出力を選択できます。 renderPrintverbatimTextOutputの代わりにrenderTabletableOutputを試すことができます。別のオプションは、DTパッケージのrenderDataTableです。これにより、異なるページに余分な行を配置してすべての行にアクセスできるようにする表が作成され、いつでも表示する行の数を変更できます。例えば

、次のようにあなたの現在のrenderPrintを置き換える:

output$IPLMatch2TeamsPrint <- DT::renderDataTable({ 
    a <- printOrPlotIPLMatch2Teams(input, output) 
    datatable(a, 
      options = list(
       "pageLength" = 40) 
) 
}) 

DT::dataTableOutput("IPLMatch2TeamsPrint")であなたのverbatimTextOutput("IPLMatch2TeamsPrint")を交換すると、あなたに40行とテーブル内の別のページとしてより多くの行を参照するためのオプションを持つテーブルを与える必要があります。

印刷だけではないので、名前を印刷から表に変更して分かりやすくすることもできます。

+0

まさに私が欲しかったもの。私はrenderTableとtableOutputを使用し、それは魅力のように機能します!ありがとう! –

関連する問題