knitrSet {Hmisc}R Documentation

knitr Setup

Description

Sets up knitr to use better default parameters for base graphics, better code formatting, and to allow several arguments to be passed from code chunk headers, such as bty, mfrow, ps, bot (extra bottom margin for base graphics), top (extra top margin), left (extra left margin), rt (extra right margin), lwd, mgp, las, tcl, axes, xpd, h (usually fig.height in knitr), w (usually fig.width in knitr), cap (character string containing figure caption), scap (character string containing short figure caption for table of figures).

Usage

knitrSet(basename=NULL, w=4, h=3,
         fig.path=if(length(basename)) basename else '',
         fig.align='center', fig.show='hold', fig.pos='htbp',
         fig.lp=paste('fig', basename, sep=':'),
         dev=switch(lang, latex='pdf', markdown='png'),
         tidy=FALSE, error=FALSE,
         messages=c('messages.txt', 'console'),
         width=61, decinline=5, size=NULL, cache=FALSE,
         echo=TRUE, results='markup', lang=c('latex','markdown'))

Arguments

basename

base name to be added in front of graphics file names. basename is followed by a minus sign.

w,h

default figure width and height in inches

fig.path

path for figures. To put figures in a subdirectory specify e.g. fig.path='folder/'.

fig.align,fig.show,fig.pos,fig.lp,tidy,cache,echo,results,error,size

see knitr documentation

dev

graphics device, with default figured from lang

messages

By default warning and other messages such as those from loading packages are sent to file 'messages.txt' in the current working directory. You can specify messages='console' to send them directly to the console.

width

text output width for R code and output

decinline

number of digits to the right of the decimal point to round numeric values appearing inside Sexpr

lang

Default is 'latex' to use LaTeX. Set to markdown when using R Markdown.

Author(s)

Frank Harrell

See Also

knit

Examples

## Not run: 
# Typical call (without # comment symbols):
# <<echo=FALSE>>=
# require(Hmisc)
# knitrSet()
# @

knitrSet()    # use all defaults and don't use a graphics file prefix
knitrSet('modeling')   # use modeling- prefix for a major section or chapter
knitrSet(cache=TRUE, echo=FALSE)  # global default to cache and not print code
knitrSet(w=5,h=3.75)   # override default figure width, height

## End(Not run)

[Package Hmisc version 3.17-4 Index]