[R] calling sweave function from latex

Sam McClatchie s.mcclatchie at niwa.co.nz
Wed Jan 29 02:13:03 CET 2003


System info:
Mandrake 9.0
R Version 1.6.1
ESS 5.1.21
Emacs 21.2.1
-------------------

Colleagues

I've been calling R-code embedded in my LaTex document using Sweave, but 
would like to make things more convenient. At present as I understand it 
  you first process the R chunks of code using the Sweave function 
called from within R to process a "precursor file" e.g. foo.sw to get a 
LaTex file (foo.sw.tex) that you then process with latex foo.sw.tex.
------------------------
example code segment

%\item {\bf Matched trawl and acoustic data} \label{real data}

\item {\bf Results}

%%%% sweave code

<<echo=false,results=hide>>=
average.trawl.spp.composition()
@

%%%% insert figure generated from sweave code
\begin{figure}
\includegraphics[scale=0.6]{../figures/bycatch_by_weight}
\caption{\label{catch by weight} Proportions of selected species (from
     Table \ref{ts length regressions}) in the fish assemblage using
     catch rate ($kg\ km{-1}$) as an approximation for fish density
     (neglecting variable capture efficiencies). Note: there were no
     oblique banded rattails in this dataset, although we have a
     \textit{<TS>-length} regression for them (see Table \ref{ts length
     regressions}). Box plot centre line = meadian, box limits are
     $25^{th}$ and $75^{th}$ quartiles, whiskers represent 1.5 times the
     interquartile range from the median, and points outside the whiskers
     are the tails of the distributions.}
\end{figure}
-----------------------

This works fine, but it is cumbersome for someone who likes to write a 
bit and then latex that additional bit. Of course I can just add the new 
LaTex code chunks to the foo.sw.tex and latex that, but I have to 
remember to copy the foo.sw.tex back to foo.sw or the versions get mixed 
up. Trivial, but annoying.

The question is: can I call the Sweave function from within LaTex so I 
just latex the foo.sw.tex and the Sweave chunks will also get processed. 
This would be much tidier.

One suspects that the short answer is 'no'.

Best fishes

Sam
-- 
Sam McClatchie, Research scientist (fisheries acoustics))))))))))
NIWA (National Institute of Water & Atmospheric Research Ltd)
PO Box 14 901, Kilbirnie, Wellington, New Zealand
s.mcclatchie at niwa.cri.nz
Research home page <http://www.smcc.150m.com/>
                       /\
            >><xX(&>
                    /// \\\
                   //// \\\\
                  ///  <%)Xx><<
                 /////  \\\\\\
           ><(((@>
     ><(((%>     ..>><xX(?>O<?)Xx><<




More information about the R-help mailing list