2

I want to print the content of a data.table to a Markdown document out of R-Studio. However, the ouput is somewhat wider, so I decreased the font, as described here: Code chunk font size in Rmarkdown with knitr and latex

However, even when decreasing the font to tiny, the line break remains although there is plenty of space to have the columns adjacent. I wonder how this can be achieved.

---
title: "mwe"
output: pdf_document
---

```
{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(data.table)
dat <- data.table(id=1:5,num=31:35,text=c("a","b","c","d","here you can find some long text to artificially widen this text column and demonstrate the problem"))
```
Here is some text.

\tiny
```{r}
dat

```

output2dat[5]

bumblebee
  • 1,116
  • 8
  • 20

1 Answers1

1

Check ?options and look for the parameter width that controls the number of columns printed per line:

---
title: "mwe"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(data.table)
dat <- data.table(id=1:5,num=31:35,text=c("a","b","c","d","here you can find some long text to artificially widen this text column and demonstrate the problem"))
```

\tiny
```{r}
dat
```

```{r}
options(width = 120)
dat
```
 

enter image description here

Martin Schmelzer
  • 23,283
  • 6
  • 73
  • 98