2017-06-05 85 views
1

當我運行下面的代碼時,我只能得到1或2行數據。我如何增加顯示的行數?謝謝!DT在DT中顯示更多行

--- 
    title: " File Analysis" 
    output: 
    html_document: default 
    pdf_document: default 
    word_document: default 
    --- 

    ```{r setup, include=FALSE} 
    knitr::opts_chunk$set(echo = FALSE,comment = NA, echo=FALSE,message= FALSE, warning = FALSE) 
    ``` 
    **As can be seen in Table 1 below** 
    ```{r echo=FALSE, message=FALSE,warning = FALSE} 
    cwater<-matrix(rbinom(10*100, 1, .5), ncol=10) 

    library("knitr","xtable", quietly = TRUE) 
    library(DT, quietly = TRUE) 
    datatable(cwater, caption = 'Table 1: This is a searchable table of the  water content.', 
    class = 'cell-border stripe', filter = 'top',extensions = 'Buttons',fillContainer=TRUE, options = list(
    pageLength = 10, autoWidth = TRUE,dom = 'Bfrtip',buttons = c ('copy', 'print'), scrollX = TRUE, 
selection="multiple" 
    )) 
    ``` 

回答

0

你需要增加容器的大小或關閉「fillContainer」選項:

--- 
title: "DT Table Example" 
output: 
    html_notebook: 
    toc: true 
    number_sections: false 
    theme: united 
    highlight: tango 
--- 

```{r setup, include=FALSE} 
knitr::opts_chunk$set(echo = FALSE,comment = NA, echo=FALSE,message= FALSE, warning = FALSE) 
``` 
**Turn off the 'fillContainer' option** 
```{r echo=FALSE, message=FALSE,warning = FALSE} 
cwater<-matrix(rbinom(10*100, 1, .5), ncol=10) 

library("knitr","xtable", quietly = TRUE) 
library(DT, quietly = TRUE) 
datatable(cwater, 
      caption = 'Table 1: This is a searchable table of the water content.', 
      class = 'cell-border stripe', 
      filter = 'top', 
      extensions = 'Buttons', 
      fillContainer = FALSE, 
      options = list(pageLength = 10, 
         autoWidth = TRUE, 
         dom = 'Bfrtip', 
         buttons = c('copy', 
            'print'), 
         scrollX = TRUE, 
      selection="multiple" 
     )) 
```