Mark Wardle | 14 Oct 23:56

Sweave, R and complex latex projects

Hello all,

I've been able to use R very successfully to run simple statistics and
generate the plots I require.

I've been evaluating Sweave, and have hit upon a small problem that I
don't seem to be able to workaround. Sweave runs very well for single
file latex documents, but I have a complex thesis made up of several
parts and chapters. These are arranged with a master latex file and
subdirectories with "\include"-ed latex fragments representing those
parts/chapters, and I don't seem to be able to get Sweave to work properly.

I've tried a number of approaches, including converting the master
document into a Snw file itself, or even generating chapters manually
chapter by chapter using Sweave and then "\include"ing the result into
the master tex file. Unfortunately for the latter attempt, the the latex
generated doesn't prepend the required path to the filename, and so
latex looks for the pdfs and tex files in the wrong place - it looks in
the "root" directory (where the master tex file is located) rather than
the chapter subdirectory where all the files have been generated.

I hope I'm not missing something obviously documented, but I can't see
it in the Sweave docs. Is there an option to prepend a pathname to the
filename of Sweave generated TeX and PDF documents?

Do people use Sweave for complex multi-file latex projects, and what is
the best approach? I'm almost tempted to keep R and Latex separate, and
continue to run a R script to generate all of the dynamic tables/charts
which are then "\input"ed, but I was rather attracted to the whole
Sweave approach.
(Continue reading)

Deepayan Sarkar | 15 Oct 01:04

Re: Sweave, R and complex latex projects

On 10/14/06, Mark Wardle <mark <at> wardle.org> wrote:
> Hello all,
>
> I've been able to use R very successfully to run simple statistics and
> generate the plots I require.
>
> I've been evaluating Sweave, and have hit upon a small problem that I
> don't seem to be able to workaround. Sweave runs very well for single
> file latex documents, but I have a complex thesis made up of several
> parts and chapters. These are arranged with a master latex file and
> subdirectories with "\include"-ed latex fragments representing those
> parts/chapters, and I don't seem to be able to get Sweave to work properly.
>
> I've tried a number of approaches, including converting the master
> document into a Snw file itself, or even generating chapters manually
> chapter by chapter using Sweave and then "\include"ing the result into
> the master tex file. Unfortunately for the latter attempt, the the latex
> generated doesn't prepend the required path to the filename, and so
> latex looks for the pdfs and tex files in the wrong place - it looks in
> the "root" directory (where the master tex file is located) rather than
> the chapter subdirectory where all the files have been generated.
>
> I hope I'm not missing something obviously documented, but I can't see
> it in the Sweave docs. Is there an option to prepend a pathname to the
> filename of Sweave generated TeX and PDF documents?
>
> Do people use Sweave for complex multi-file latex projects, and what is
> the best approach? I'm almost tempted to keep R and Latex separate, and
> continue to run a R script to generate all of the dynamic tables/charts
> which are then "\input"ed, but I was rather attracted to the whole
(Continue reading)

Friedrich Leisch | 16 Oct 11:28

Re: Sweave, R and complex latex projects

>>>>> On Sat, 14 Oct 2006 16:04:50 -0700,
>>>>> Deepayan Sarkar (DS) wrote:

  > %.tex: %.Rnw
  >         echo "library(tools); Sweave('$<')" | ${R_PROG} --vanilla --silent

Note that we now have R CMD Sweave (new in R 2.4.0) for this purpose.

Best,
Fritz

______________________________________________
R-help <at> stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dirk Eddelbuettel | 16 Oct 15:51

Re: Sweave, R and complex latex projects


On 16 October 2006 at 11:28, Friedrich Leisch wrote:
| >>>>> On Sat, 14 Oct 2006 16:04:50 -0700,
| >>>>> Deepayan Sarkar (DS) wrote:
| 
| 
| 
|   > %.tex: %.Rnw
|   >         echo "library(tools); Sweave('$<')" | ${R_PROG} --vanilla --silent
| 
| Note that we now have R CMD Sweave (new in R 2.4.0) for this purpose.

It would have been nice if that followed convention and responded to --help
as suggested by 'R --help':

edd <at> basebud:~$ R --help | tail -5

Please use 'R CMD command --help' to obtain further information about
the usage of 'command'.

Report bugs to <r-bugs <at> r-project.org>.
edd <at> basebud:~$ 

yet what we get is an error:

edd <at> basebud:~$ R CMD Sweave --help
> library("utils"); Sweave("--help")
Writing to file --help.tex
Processing code chunks ...
Error in SweaveReadFile(file, syntax) : no Sweave file with name '--help' found
(Continue reading)

Friedrich Leisch | 16 Oct 11:27

Re: Sweave, R and complex latex projects

>>>>> On Sat, 14 Oct 2006 23:00:27 +0100,
>>>>> Mark Wardle (MW) wrote:

  > Hello all,
  > I've been able to use R very successfully to run simple statistics and
  > generate the plots I require.

  > I've been evaluating Sweave, and have hit upon a small problem that I
  > don't seem to be able to workaround. Sweave runs very well for single
  > file latex documents, but I have a complex thesis made up of several
  > parts and chapters. These are arranged with a master latex file and
  > subdirectories with "\include"-ed latex fragments representing those
  > parts/chapters, and I don't seem to be able to get Sweave to work properly.

  > I've tried a number of approaches, including converting the master
  > document into a Snw file itself, or even generating chapters manually
  > chapter by chapter using Sweave and then "\include"ing the result into
  > the master tex file. Unfortunately for the latter attempt, the the latex
  > generated doesn't prepend the required path to the filename, and so
  > latex looks for the pdfs and tex files in the wrong place - it looks in
  > the "root" directory (where the master tex file is located) rather than
  > the chapter subdirectory where all the files have been generated.

  > I hope I'm not missing something obviously documented, but I can't see
  > it in the Sweave docs. Is there an option to prepend a pathname to the
  > filename of Sweave generated TeX and PDF documents?

Yes, simply set prefix.string to a path, not only a filename. E.g.,

\SweaveOpts{prefix.string=figs/myfile}
(Continue reading)

Mark Wardle | 16 Oct 19:04

Re: Sweave, R and complex latex projects

Friedrich Leisch wrote:
>>>>>> On Sat, 14 Oct 2006 23:00:27 +0100,
>>>>>> Mark Wardle (MW) wrote:
> 
>   > Hello all,
>   > ...

> Yes, simply set prefix.string to a path, not only a filename. E.g.,
> ...

Many thanks for everyone's help on this (both on and off list). Working
perfectly now!

Now I just need help with ....  !

Only joking, although it will only be a matter of time!

Best wishes,

Mark

______________________________________________
R-help <at> stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Mark Wardle | 9 Nov 21:02

Re: Sweave, R and complex latex projects

All,

This is an update to my previous query on dealing with complex (complex
in my eyes anyway) LaTeX/Sweave projects. Based on the work of others,
please see my current thesis Makefile below. I didn't get Sweave and
LaTeX to cope with a master document in one directory, and chapters in
subdirectories, so instead I moved all individual chapter .tex and .Rnw
files into the same directory. The only reason for having directories in
the first place was to group all the charts and tables etc. and Sweave
makes that unnecessary anyway.

The other issue is that Sweave can interact with typeface settings in a
LaTeX document. One may avoid this by using the [noae] option, or just
making sure any typeface directives (including \usepackage{times}) come
after the \usepackage{Sweave} directive in your master LaTeX document.

I hope this is of help to someone else... No guarantees as I am not a
Makefile expert!

#
# Makefile
#
#
# Global project Makefile
#
#
# This makefile was based on
#
http://209.85.135.104/search?q=cache:-fU4UEn36AgJ:kriemhild.uft.uni-bremen.de/viewcvs/Makefile.rnoweb+makefile+sweave+latex&hl=en&ct=clnk&cd=10&client=safari
# (The original file found on Google is no longer available and I
(Continue reading)


Gmane