Adding a table of contents to PDF with R plots

前端 未结 3 954
渐次进展
渐次进展 2021-02-09 03:35

I\'m creating a larger number of plots in R and save them as PDF (using grDevices / pdf). Is there an easy way to add a (meta-data) table of contents to the PDF as it is created

3条回答
  •  我寻月下人不归
    2021-02-09 04:05

    You could create a first page using the names of your objects or plots as the arguments to text in columns.

    plot(1:10,1:10, type="n", main ="Index", axes=FALSE,frame.plot=FALSE,xlab="")
    
    text(1,10, "plot")
    text(3,10, "page")
    text(5,1:10, rev(1:10+1))
    text(2,1:10, rev(letters[1:10]))
    

    Base graphics version

    I cannot think of a way to generate a navigable TOC, but this option may be more pleasing and easier to integrate with Beamer-type displays. The Hmisc package function latex provides an interface to the Latex longtable package. My Latex-fu is weak but if yours is stronger, you could also divert the dvi code that is created for integration within other applications. I get an intermediate dvi file put in a temporary directory which then opens my dvi viewer and allows saving as pdf:

    require(Hmisc)
    ?latex  # you will probably want to review this
    latex(Plot_list<-data.frame(Plots=letters[1:10], Pages=2:11))
    

    enter image description here

提交回复
热议问题