Reputation: 891
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.
Upvotes: 18
Views: 13095
Reputation: 891
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
```
Upvotes: 24