
knitrSet
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). plotlySave
saves a plotly graphic with name foo.png
where foo
is the name of the current chunk. You must have a
free plotly
account from plot.ly
to use this function,
and you must have run
Sys.setenv(plotly_username="your_plotly_username")
and
Sys.setenv(plotly_api_key="your_api_key")
. The API key can be
found in one's profile settings.
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'))
plotlySave(x, ...)
basename
is followed by a minus sign.fig.path='folder/'
.lang
'messages.txt'
in the
current working directory. You can specify
messages='console'
to send them directly to the console.'latex'
to use LaTeX. Set to
markdown
when using R Markdown.plotly
graphics object or a named list of such
objects. The resulting png
file will go in the file path
given by the knitr
fig.path
value, and have a base
name equal to the current knitr
chunk name. If x
is a
list, a minus sign followed by the chunk name are inserted before
.png
.plotly::plotly_IMAGE
knit
## 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
#
# # ```{r chunkname}
# # p <- plotly::plot_ly(...)
# # plotlySave(p) # creates fig.path/chunkname.png
# ## End(Not run)
Run the code above in your browser using DataLab