我正在使用rmarkDown创建HTML报告,该报告具有 dt :: dataTable()
函数生成的一些交互式表看一点,到目前为止,我一直无法摆脱它。
这就是数据的间距通常在数据表和下一个图之间的样子:
这是额外空间的间距:
似乎只发生了桌子上有少量的行(< 5),这使我怀疑它的空间至少为10行。基于此,我尝试设置DataTable选项 pageLength = 5
和 lentheMenu = c(5、10、15、20)
,也尝试了 fillContainer = false ,但到目前为止尚无奏效。
下面显示了直接生成表和图的代码,并从单独的函数中调用,因为除了每次不同输入的其他图外,我还创建了大量表。该图是GGPLOT对象。
model_obj$data %>%
DT::datatable(extensions = 'Buttons',
options = list(dom = 'Blfrtip',
buttons = c('excel'))) %>%
knitr::knit_print() %>%
cat()
cat("\n\n#### Title \n\n")
print(model_obj$plot1)
I'm creating an html report with rmarkdown that has some interactive tables generated by the DT::datatable()
function and for some of them there is extra whitespace under the table which makes the formatting of the report look a little off and so far I have been unable to get rid of it.
This is what the spacing looks like normally between the datatable and the next plot:

This is what the spacing looks like with the extra space:

It seems to only be happening with tables that have a small number of rows (<5) which made me suspect its holding the space for a table with a minimum of 10 rows. Based on this, I tried setting the datatable options pageLength = 5
and lengthMenu = c(5, 10, 15, 20)
and also tried fillContainer = FALSE
but nothing so far has worked.
The code to generate the tables and plots directly under is shown below and is called from a separate function because I'm creating a large number of tables in addition to other plots with different inputs each time. The plot is a ggplot object.
model_obj$data %>%
DT::datatable(extensions = 'Buttons',
options = list(dom = 'Blfrtip',
buttons = c('excel'))) %>%
knitr::knit_print() %>%
cat()
cat("\n\n#### Title \n\n")
print(model_obj$plot1)
发布评论