rstudio / rmarkdown-cookbook

R Markdown Cookbook. A range of tips and tricks to make better use of R Markdown.
https://bookdown.org/yihui/rmarkdown-cookbook/
578 stars 224 forks source link

Chaptern5.3/Addition #398

Open CarstenLange opened 12 months ago

CarstenLange commented 12 months ago

Hi Yihui,

I am currently writing a book with CRC Press, and I found a lot of advice in your posts and books. Thank you!!!

Recently I had a problem with R output too wide for the CRC PDF format. I followed your advice from Chapter 5.3.;

So, I came up with a hack that might be useful for others (or not :) );

library(tidyverse)
print(str(diamonds)) #Output too wide
WideOutputVector=capture.output(str(diamonds))
NarrowOutputVector=strtrim(WideOutputVector, 30)
cat(NarrowOutputVector,sep = "\n")

I thought it might help somebody who has a similar problem as I had.

Best,

Carsten …………………………………………….. Carsten Lange, Ph.D. Professor of Economics and Graduate Coordinator California State University 3801 West Temple Ave. Pomona, CA 91768 Phone: +1 (909) 869 3843 Email: clange@cpp.edu

cderv commented 11 months ago

Thanks for sharing !