简体   繁体   中英

How can i enlarge a datatable in the R DT package?

I am attempting to create an R markdown pdf_document but the tables I am incorporating are coming out too small on the page

As a first step, I have tried to increase the height and width (hoping the font size would increase accordingly) of the initial DT datable but I cannot even get that working

DT::datatable(head(iris, 20) 

and

DT::datatable(head(iris, 20), height = '1200px', width='1200px')

both result in an image this size在此处输入图片说明

which appears even smaller in the pdf output

Any help appreciated

You can set the table width to 100% (the default is a fixed width 960px ), then decrease the figure width so text can be larger. This is because your PDF page width is fixed. The larger your screenshot is, the smaller the text will be. An example:

---
title: "test"
output: pdf_document
---


```{r fig.width=5}
DT::datatable(head(iris, 20), width = '100%')
```

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM