[R] recommended way to group function calls in Sweave

Duncan Murdoch murdoch.duncan at gmail.com
Wed Apr 25 17:17:01 CEST 2012


On 25/04/2012 10:20 AM, Liviu Andronic wrote:
> On Wed, Apr 25, 2012 at 3:41 PM, Duncan Murdoch
> <murdoch.duncan at gmail.com>  wrote:
> >  I would use the last method, or if the calls were truly repetitive (i.e.
> >  always identical, not just the same pattern), use a named chunk.
> >
> Labeled chunks are indeed what I was looking for [1]. As far as I
> understand, this is what "Sweave functions" (or are these macros?)
> look like:

Yes.  They're definitely macros, not functions:  pure text substitution.

Duncan Murdoch
>
>
> <<>>=
> d<- iris
> ind<- 1:2
> @
>
> <<sw>>=
>    summary(d[ , ind])
>    cor(d[ , ind])
> @
>
> <<>>=
> d<- iris
> ind<- 2:4
> <<sw>>
> @
>
>
> Regards
> Liviu
>
> [1] vignette('Sweave', 'utils')



More information about the R-help mailing list