I have a R markdown document in RStudio, where a data.table is printed. I want to set the data frame print options to control printed number of rows and columns, as described here.
Here is a minimal example .Rmd file:
---
output:
html_document:
fig_height: 8
fig_width: 10
df_print: paged
---
```{r}
knitr::opts_chunk$set(echo = FALSE)
cars
```
Where/how do I set the rows.print
option?
I've tried this:
---
output:
html_document:
fig_height: 8
fig_width: 10
df_print: paged
rows.print: 25
---
which doesn't work (still at default 10 rows), and this:
```{r}
knitr::opts_chunk$set(echo = FALSE, rows.print=25)
cars
```
which also doesn't work.
Syntax in Rmarkdown To implement the tabbed section in an Rmarkdown document like the example above, all you have to do is putting {. tabset} on the right of a header. Then all the content below each sub-header will appear within a tab.
There are two types of output formats in the rmarkdown package: documents, and presentations.
To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.
The knitr::opts_chunk$set(rows.print=25)
option setting applies only to subsequent chunks, hence in the minimal example it doesn't change the setting.
The option can be set in the chunk as shown in chunk1
or globally in opts_chunk
for subsequent chunks.
```{r chunk1, rows.print=15}
knitr::opts_chunk$set(echo = TRUE, rows.print=25)
cars #15 rows printed
```
```{r chunk2}
cars #25 rows printed
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With