简体   繁体   中英

Avoid spilling of text to margin when using R markdown and knitr

While generating a pdf file using rmarkdown and knitr , how to avoid spilling of text of R console output to the margins? For example,

---
title: "Illustration"
author: "Temp"
date: "Monday, April 06, 2015"
output: pdf_document
---

Spilling of R output.

```{r}
library("tm")
data("acq")
str(acq)
```

I have found the most consistent way for me to deal with this is to use the width and strict.width options to the str() function . The width option specifies the page width to be used and is supposed to inherit from the active options() setting for width. But, I haven't always found this consistent. The strict.width allows you to control how the excess text is handled (cut, wrapped).

---
title: "Illustration"
author: "Temp"
date: "Monday, April 06, 2015"
output: pdf_document
---

Spilling of R output.

```{r}
library("tm")
data("acq")
str(acq,width=80,strict.width="cut")
```

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