easiest way to write a title page to pdf without Sweave

SFun28 picture SFun28 · Apr 19, 2011 · Viewed 9.4k times · Source

I have R code (using ggplot2) that pumps out a bunch of charts to PDF and I'm happy with the layout. I just want to slap on a decent-looking title page which is just some centered text. Google seems to produce a lot of support for Sweave - except that the workflow is really bizarre to me (i.e. embed my R in sweave, run sweave from R). Also, I don't want to onboard a bunch of new programs to get this to work. Also, I have a ton of R code that produces the charts and I'm happy with the flow-of-control (i.e. run r script, r script writes plots to pdf). Ideally, I just want to print a title page to the PDF, print my plots, close the device, and call it a day. How would I do this?

Answer

Greg picture Greg · Apr 19, 2011

Since you want to do it totally within R, this could work, but it is a poor substitute for using actual typesetting software (as opposed to statistical analysis software) to make title pages:

#pdf(...)
plot(0:10, type = "n", xaxt="n", yaxt="n", bty="n", xlab = "", ylab = "")


text(5, 8, "This is the title")
text(5, 7, "This is my name")

text(5, 6, "This is the date")

#plot(...)/xyplot(...)/ggplot(...) your plots

#dev.off()

Title Page in R