Last active
January 16, 2019 23:53
-
-
Save tomhopper/d85d7a34ca4e674a563c485676a5d23d to your computer and use it in GitHub Desktop.
Revisions
-
tomhopper revised this gist
Jan 16, 2019 . 1 changed file with 16 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,19 @@ First-thing at the top of the Rmd file, after the YAML header, is the following css style block. <style> pre { overflow-x: auto; } pre code { word-wrap: normal; white-space: pre; } </style> (Thanks to [this answer](https://stackoverflow.com/a/36846864/393354) by rawr on Stack Overflow.) Alternatively, this css could be included in a css file that is included in the document via the YAML headers, like so: --- -
tomhopper created this gist
Jan 16, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ <style> pre { overflow-x: auto; } pre code { word-wrap: normal; white-space: pre; } </style> First-thing at the top of the Rmd file, after the YAML header, is the above css style block. Alternatively, this could be included in a css file that is included in the document via the YAML headers, like so: --- title: "Document Title" author: "John Author" date: '`r format(Sys.Date(), "%B %Y")`' output: html_document: css: custom_css.css --- When we want to have a code chunk that scrolls, we use code blocks to save the current output width for R, then set a wide output width. ```{r, include=FALSE} set_width <- getOption("width") options(width = 999) ``` Then we produce our wide output, being sure to set the `tidy=FALSE` chunk option. ```{r, tidy=FALSE} mtcars %>% skim() ``` Finally, we set the output width back to the previous value so that future code blocks will produce the normally-expected formatting. ```{r, include=FALSE} options(width = set_width) ```