How can I suppress output from Sweave that is not suppressed by echo = FALSE?

I get extraneous output in my .tex file, which I cannot suppress with <> or sink (). It is noteworthy that unwanted strings are not enclosed in .. {Schunk} or similar.

This happens to me when I use either DEoptim or rjags, although this is probably not limited to these functions.

Example .Rnw file:

\documentclass[a4paper, 12]{article} begin{document} <<echo=FALSE>>= require(DEoptim) Rosenbrock <- function(x){ #example from DEoptim authors x1 <- x[1] x2 <- x[2] 100 * (x2 - x1 * x1)^2 + (1 - x1)^2 } lower <- c(-10,-10) upper <- -lower set.seed(1234) DEoptim(Rosenbrock, lower, upper) @ \end{document} 

What I want to do The result that I would like is a tex file that will be created if the output was suppressed or, what is the same, if a piece of code has been removed from the .Rnw file:

 \documentclass[a4paper, 12]{article} \usepackage{Sweave} \begin{document} \end{document} 

What happens However, the resulting .tex file has a function exit:

 \documentclass[a4paper, 12]{article} \usepackage{Sweave} \begin{document} Iteration: 1 bestvalit: 132.371451 bestmemit: -1.851683 4.543355 Iteration: 2 bestvalit: 8.620563 bestmemit: -1.854371 3.369908 ....few hundred lines of DEoptim output .... $member$storepop list() attr(,"class") [1] "DEoptim" \end{document} 

Note that the output is not enclosed in \ begin {Schunk} \ end {Schunk}, so the $ signs mix LaTeX and it will not compile.

+6
r sweave latex
source share
2 answers

The output comes from calling a compiled function (C or Fortran) in DEoptim.

This produces a clean output:

 \documentclass[a4paper, 12]{article} \begin{document} \section{Computation in R} <<computation,results=hide>>= require(DEoptim) Rosenbrock <- function(x){ x1 <- x[1] x2 <- x[2] 100 * (x2 - x1 * x1)^2 + (1 - x1)^2 } lower &lt;- c(-10,-10) upper &lt;- -lower set.seed(1234) res &lt;- DEoptim(Rosenbrock, lower, upper) @ \section{Results} <<results>>= res$optim @ \end{document} 
+6
source share

You tried

 <<echo=FALSE, results=hide>> 

?

+7
source share

All Articles