Data Science Desktop Survival Guide
by Graham Williams |
|||||
Knitr Options |
Raw We have explored only some of the functionality of knitr and LaTeX. Together there is virtually nothing they can not do—being programming languages anything that can be done, can be done using these tools.
As a summary below we list the common knitr options. The options are added to the chunk start line or else we can set the options using opts_chunk$set(). The arguments to the function can be any number of named options with their values. For example:
# Set global defaults for knitr options.
opts_chunk$set(size="footnotesize", message=FALSE, tidy=FALSE)
Once this is run, the options remain in force as the default values until they are again changed using opts_chunk$set(). They can be overriden per chunk in the usual way.
|
background="#F7F7F7" # The background colour of the code chunks.
cache.path="cache/" # comment=NA # Suppresses "\verb|## |" in R output. echo=FALSE # Do not show R commands—just the output. echo=3:5 # Only echo lines 3 to 5 of the chunk. eval=FALSE # Do not run the R code—its just for display. eval=2:4 # Only evaluate lines 2 to 4 of the chunk. fig.align="center" # fig.cap="Caption..." # fig.keep="high" # fig.lp="fig:" # Prefix for the label assigned to the figure. fig.path="figures/plot" # fig.scap="Short cap." # For the table of figures in the contents. fig.show="animate" # Collect figures into an animation. fig.show="hold" # fig.height=9 # Height of generated figure. fig.width=12 # Width of generated figure. include=FALSE # Include code but not output/picture. message=FALSE # Do not display messages from the commands. out.height=".6\\textheight" # Figure takes up 60\% of the page height. out.width=".8\\textwidth" # Figure takes up 80\% of the page width. results="markup" # The output from commands will be formatted. results="hide" # Do not show output from commands. results="asis" # Retain R command output as \LaTeX{} code. size="footnotesize" # Useful for Beamer slides. tidy=FALSE # Retain my own formatting used in the R code.
New options defined in this Chapter and used in this book:
|
out.lines=4 # Number of lines of \R{} output to show.
out.truncate=80 # Truncate \R{} output lines beyond this. src.bot=NULL # Number of lines of output at top to show. src.top=NULL # Number of lines of output at bottom to show.
|