[R] Long lines with Sweave

Jan T. Kim jtk at cmp.uea.ac.uk
Wed Sep 14 11:13:01 CEST 2005


On Wed, Sep 14, 2005 at 10:14:59AM +0200, Henrik Andersson wrote:
> I have used Sweave a lot the latest year, but never really used any long 
> function calls.
> 
> 
> If I have code which look like this
> 
> -------------------------------------------------------------
> gof <- benthic.flux(ID="Gulf of Finland",
>                      meas.conc=conc,
>                      bw.conc=bw.conc,
>                      time=times,
>                      substance=expression(DIC~(mmol~m^{-3}))
>                      )
> -------------------------------------------------------------
> 
> I get the output by Sweave in my pdf file, like this:
> 
> ---------------------------------------------------------------
>  > gof <- benthic.flux(ID = "Gulf of Finland", meas.conc = conc,
> + bw.conc = bw.conc, time = times, substance = expression(DIC ~
> + (mmol ~ m^{
> + -3
> + })))
> ----------------------------------------------------------------
> 
> I can understand that it will not look exactly as entered but why is the 
> '-3' on a line of it's own?
> 
> Can anyone suggest a idea to how I can make this more readable.

It seems you've been thinking LaTeX rather than R ;-)  :
The exponent "-3" in the expression should be enclosed by parentheses
rather than by curly braces.

The code formatting done by the print method inserts the newline after
"{" and before "}".

Best regards, Jan
-- 
 +- Jan T. Kim -------------------------------------------------------+
 |    *NEW*    email: jtk at cmp.uea.ac.uk                               |
 |    *NEW*    WWW:   http://www.cmp.uea.ac.uk/people/jtk             |
 *-----=<  hierarchical systems are for files, not for humans  >=-----*




More information about the R-help mailing list