Writing big documents with Sweave. Is it possible to do as with LaTeX?

后端 未结 3 1878
名媛妹妹
名媛妹妹 2021-01-30 09:18

I am just discovering Sweave and R. I have seen some examples of Sweave documents and have also started to write one or two on my own. I a

3条回答
  •  爱一瞬间的悲伤
    2021-01-30 09:55

    Here is what works very well for me:

    I have one master file ("master.Rnw") that has no text but only serves to collect the files (chapters, sections) which form the document in the end.

    Then I have one file with R code that is being reused in various other files ("func.Rnw"). Here, I have lot of named chunks

    <>=
    # code:
    c <- a * b
    @
    

    In master.Rnw, the first thing after \begin{document} I do is

    \SweaveInput{func.Rnw}
    

    and from there, I have my named chunks available. In a file "chap1.Rnw" I can now have

    <>=
    a <- 10
    b <- 25
    <>
    c
    @
    

    Of course, I have to

    \SweaveInput{chap1.Rnw})
    

    into master.Rnw.

    I only have to \Sweave{master.Rnw} and then pdflatex the resulting master.tex file, no copying/ pasting or processing of multiple files.

    I'm just writing a paper of 60+ pages with about 25 tables and figures and everything works perfectly well so far.

    Hope this helps, Rainer

提交回复
热议问题