Reputation: 789
I am done with all analysis and would like to output a summary report in only one pdf file. The first page, I would like to write bold and big "Report" in the middle. Second page, I would like to insert a table(I have this data frame in R) with a very short table title. The rest pages are my graphs. One page, one graph.
Currently,my pdf file only have four pages. Any idea that I can the first page and second page. Thank you!
pdf()
plot1 #page 1
plot2 #page 2
plot3 #page 3
plot4 #page 4
dev.off()
Upvotes: 3
Views: 6386
Reputation: 12640
Here's a Sweave version of what you want:
\documentclass[a4paper, titlepage]{article}
\title{Report}
\author{}
\date{}
\begin{document}
\SweaveOpts{concordance=TRUE}
\makeatletter
\vspace*{\fill}
{\centering\Huge\bfseries\@title\par}
\vspace*{\fill}
\makeatother
\newpage
\subsection*{Table}
<<results=tex, echo=FALSE>>=
library(xtable)
print(xtable(data.frame(x = rnorm(20), y = rnorm(20))), floating = FALSE)
@
\newpage
\subsection*{Plot 1}
<<plot1, fig=TRUE, echo=FALSE>>=
plot(rnorm(100))
@
\newpage
\subsection*{Plot 2}
<<plot2, fig=TRUE, echo=FALSE>>=
plot(rnorm(100))
@
\newpage
\subsection*{Plot 3}
<<plot3, fig=TRUE, echo=FALSE>>=
plot(rnorm(100))
@
\newpage
\subsection*{Plot 4}
<<plot4, fig=TRUE, echo=FALSE>>=
plot(rnorm(100))
@
\end{document}
You should save it as "MyReport.Rnw" and then can compile it using
Sweave("MyReport.Rnw")
tools::texi2pdf("MyReport.tex")
RStudio has a great interface for compiling PDFs from .Rnw files. You can also knitr
with LaTeX formatted files (as opposed to RMarkdown). You'll need to run the above file through knitr::Sweave2knitr("MyReport.Rnw")
first. You can even use a LaTeX editor Lyx with knitr (see http://yihui.name/knitr/demo/lyx/).
Upvotes: 7