MYaseen208
MYaseen208

Reputation: 23898

knitr showing R Chunk Code output after whole block of R Chunk Code

I wonder how to show the R Chunk Code output after whole block of R Chunk Code not the output after each code line.

\documentclass{article} 
\begin{document}

<< Test >>=
1:10
args(lm)
@ 
\end{document}

Upvotes: 0

Views: 543

Answers (2)

Marcin
Marcin

Reputation: 8044

It looks like those chunks come from Sweave.

I would suggest to first present only code, and then to present only results. This means you would have to double your chunks, but a copy of every chunk would have to have a different chunk option. Like this:

\documentclass{article} 
\begin{document}

here are chunks that will generate only code

<< Test1, results='hide' >>=
1:10
args(lm)
@
<< Test2, results='hide' >>=
2:5
args(lm)
@ 

and here are chunks that will generate only results

<< Test3, echo=FALSE >>=
1:10
args(lm)
@
<< Test4, echo=FALSE >>=
2:5
args(lm)
@ 
\end{document}

I wish I didn't make mistake with those chunk options name, cose Im rather familiar with knitr insead od sweave.

If you want to learn knitr visit webiste of this RNINJA

Upvotes: 0

Koundy
Koundy

Reputation: 5503

Are you writing in Rmarkdown ?? If so, there is an option you can add in R chunk like

```{r,results = "hold"}

your R code

```

Otherwise you should figure out how to give this argument to knitr while converting.

Upvotes: 3

Related Questions