Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chaptern5.3/Addition #398

Open
CarstenLange opened this issue Sep 14, 2023 · 1 comment
Open

Chaptern5.3/Addition #398

CarstenLange opened this issue Sep 14, 2023 · 1 comment

Comments

@CarstenLange
Copy link

CarstenLange commented Sep 14, 2023

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.;

  • options(width) was not respected (you described this in your book)
  • I did not dare to use the listings package because I was afraid it might impact other parts of my book.

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: [email protected]

@cderv
Copy link
Collaborator

cderv commented Sep 22, 2023

Thanks for sharing !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants