Hi Francesco,

This is an advanced topic in knitr; it is called a chunk hook:
http://yihui.name/knitr/hooks

Sorry for the confusion on the name "par"; you can call it anything, e.g. mypar

knit_hooks$set(mypar = function(before, options, envir) {
  if (before) par(mar = c(4, 4, .1, .1))
})
opts_chunk$set(mypar = TRUE)

For par(bg=rgb(runif(1), runif(1), runif(1))), it is nothing but a
line of normal R code.

Regards,
Yihui
--
Yihui Xie <xieyi...@gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA


On Wed, Jan 9, 2013 at 2:59 AM, Francesco Sarracino
<f.sarrac...@gmail.com> wrote:
> Dear Yihui,
>
> thanks a lot for your kind reply. Your solution is very elegant and
> versatile.
> However, there is a point that is obscure to me and I didn't manage to fully
> understand them after looking at the Knitr manual and graphic manual.
> The issue concerns the hook:
>
> knit_hooks$set(par = function(before, options, envir) {
>   if (before) par(mar = c(4, 4, .1, .1))
> })
>
> why do you set par as a function?
> moreover, below you write:
>
> par(bg=rgb(runif(1), runif(1), runif(1)))
>
> does this mean that before = rgb(runif(1)); options = runif(1) and envir =
> runif(1) ?
>
> and what does this produce? I don't understand what's going on, can you
> please help me or address me to some documentation?
>
> thanks in advance for your kind help,
> f.
>

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to