[R] Sweave, beamer and alert within code chunks

2012-05-09 Thread Giovanni Petris

Hi all,

Using Beamer, in order to highlight a piece of R code I do something
like this - note the \structure and \alert commands:

\begin{semiverbatim}
 mleOut - \structure{dlmMLE}(Nile,
+  parm = c(0.2, 120), # initial values for optimizer
+  lower = c(1e-7, 0)) \alert2{# V must be positive}
 mleOut$convergence  \alert3{# always check this!!!}
[1] 0
\end{semiverbatim}

How can I get a similar effect using Sweave?

Thank you in advance!

Best,
Giovanni Petris


-- 

Giovanni Petris  gpet...@uark.edu
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/

__
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.


Re: [R] Sweave, beamer and alert within code chunks

2012-05-09 Thread Yihui Xie
Syntax highlighting is easy with the highlight package, on which the
knitr package is based, e.g.

- sample source: https://gist.github.com/1803930
- sample pdf: https://github.com/downloads/yihui/knitr/knitr-beamer.pdf

It is possible to insert \alert{} with knitr, but you have to provide
the logic: where do you want to insert them? use \alert{} on all
comments?

Anyway, here is a demo:

- source: https://gist.github.com/2629886#file_knitr_alert.rnw
- output: https://github.com/downloads/yihui/knitr/knitr-alert.pdf

The knitr hooks allows you to wrestle with R code and output in any
way you want, and you may need one hour or two learning the design.

BTW, I'm not sure if it is my problem or yours -- your code does not
actually run under my R 2.15.0. Long live the reproducible research!

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, May 9, 2012 at 4:13 PM, Giovanni Petris gpet...@uark.edu wrote:

 Hi all,

 Using Beamer, in order to highlight a piece of R code I do something
 like this - note the \structure and \alert commands:

 \begin{semiverbatim}
 mleOut - \structure{dlmMLE}(Nile,
 +                  parm = c(0.2, 120), # initial values for optimizer
 +                  lower = c(1e-7, 0)) \alert2{# V must be positive}
 mleOut$convergence  \alert3{# always check this!!!}
 [1] 0
 \end{semiverbatim}

 How can I get a similar effect using Sweave?

 Thank you in advance!

 Best,
 Giovanni Petris


 --

 Giovanni Petris  gpet...@uark.edu
 Associate Professor
 Department of Mathematical Sciences
 University of Arkansas - Fayetteville, AR 72701
 Ph: (479) 575-6324, 575-8630 (fax)
 http://definetti.uark.edu/~gpetris/


__
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.