R, ggplot2, introducing graph elements sequentially during presentation

I use ggplot2 for graphing. I want to use charts to create a presentation with a keynote presentation.

During the presentation, I want to consistently introduce various elements of the plot. Firstly, points corresponding to condition A, then points corresponding to condition B, and then some curves, for example.

I thought that maybe I could create the whole plot and export it in such a way that I could manipulate individual elements in keynote (for example, delete points of one condition). Thanks to the people from stackoverflow, I was able to do this: R, export the file to the keynote

But I found that it is very difficult to highlight individual elements in the master record. So, I wonder if there is an even more efficient way.

+5
source share
1 answer

If you want to use several different tools, it is very comfortable with Sweave, and LaTeXthe document class beamerfor the slide:

\documentclass{beamer}
\title{Sequential Graphs}
\begin{document}

\frame{\titlepage}

\frame{
Here a graph:
<<echo = FALSE,fig = TRUE>>=
library(ggplot2)
d1 <- data.frame(x = 1:20, y = runif(20),grp = rep(letters[1:2],each = 10))
p <- ggplot(data = d1, aes(x = x, y = y)) + geom_point()
print(p)
@
}

\frame{
Here the next graph:
<<echo = FALSE,fig = TRUE>>=
p <- p +geom_line(aes(group = 1))
print(p)
@
}

\frame{
Here the last graph:
<<echo = FALSE,fig = TRUE>>=
p <- p +geom_point(aes(colour = grp))
print(p)
@
}
\end{document}

I used ggplothere because it has convenient syntax for adding elements to the chart, but this should work with any other graphical method in R, I would think.

+11
source

All Articles