Skip to content

Chaptern5.3/Addition #398

@CarstenLange

Description

@CarstenLange

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: clange@cpp.edu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions