David Z
David Z

Reputation: 7041

knitr: Is there a way to make multiple output of R plotting into each slide?

Suppose I have a R chuck such like:

\documentclass[xcolor=x11names,compress]{beamer}
    \begin{frame}[fragile]{Visualization}                                                                                                                               
        <<echo=FALSE, results="asis", fig.keep="all", tidy=TRUE>>= 
        library(knitr)                                                                                                                                                  
        for (i in 1:100){
            plot(rnorm(100))
        }                                                                                                                                                                      
        @                                                                                                                                                                                         
   \end{frame} 
\end{document}

My question is how to make the 100 plots displayed in each following slide rather than keeping in one slide?

Upvotes: 2

Views: 58

Answers (1)

user2554330
user2554330

Reputation: 44887

Beamer can split slides if you give the "allowframebreaks" option. There seem to be some limits to how many pages, but this works:

\documentclass[xcolor=x11names,compress]{beamer}
\begin{document}
\begin{frame}[allowframebreaks]{Visualization}
<<echo=FALSE, fig.height=4>>=
for (i in 1:10){
    plot(rnorm(100))
}
@
\end{frame} 
\end{document}

Upvotes: 3

Related Questions