[Rd] Wishlist: Sweave: allow line breaks after forward slashes (PR#9444)
Arne Henningsen
ahenningsen at email.uni-kiel.de
Tue Jan 16 11:26:30 CET 2007
On Tuesday 16 January 2007 05:22, Duncan Murdoch wrote:
> On 1/15/2007 5:43 PM, Arne Henningsen wrote:
> > On Monday, 15. January 2007 18:44, Duncan Murdoch wrote:
> >> On 1/15/2007 11:23 AM, Arne Henningsen wrote:
> >>> [...]
> >>> I prefer to use "keep.source=FALSE", because I generally like that
> >>> Sweave takes the job to format the code chunks. Therefore, it would be
> >>> great if Sweave is allowed to introduce line breaks after forward
> >>> slashes, e.g. if deparse() adds a blank after a forward slash.
> >>> Please move this wish from "wishlst-fulfilled" to "wishlst".
> >>
> >> I don't think so. If I thought it was a reasonable request, I'd do
> >> that, but it's not. You have a perfectly general solution to your
> >> problem.
> >
> > However, setting "keep.source = FALSE" has (IMHO) one major advantage:
> > I can easily (and globally) change the width of the code chunks by
> > "options( width = XXX )", e.g. if I change the paper size, the margins or
> > the font size. With "keep.source = TRUE", I would have to reformat all
> > code chunks by hand and I generally prefer that my software (LaTeX,
> > Sweave) does this task for me. Hence, "keep.source = TRUE" is not a
> > "perfectly general solution" (at least) for me.
>
> No, you would only have to reformat the one code chunk where you set
> keep.source = TRUE. It doesn't need to be a global option.
Okay, that's true, but I have more than one code chunk that is not nicely
formatted because of "/" signs. (And I generally don't like manual
formatting ;-)).
Is there any reason for deparse() to add spaces around "+", "-", and "*"
operators but not around "/" operators?
R> deparse(parse( text = "a+b-c*d/e" ))
[1] "expression(a + b - c * d/e)"
> >> The fact that it isn't the one you want doesn't mean it needs
> >> to be listed as an outstanding issue in the bug reporting system.
> >
> > Okay. Where can I list "minor" wishes?
>
> On your to-do list?
Yes, that's a good idea!
This is my patch of /src/main/names.c:
--- names.c.orig 2007-01-16 11:03:24.000000000 +0100
+++ names.c 2007-01-16 10:30:43.000000000 +0100
@@ -149,7 +149,7 @@
{"+", do_arith, PLUSOP, 1, 2, {PP_BINARY, PREC_SUM, 0}},
{"-", do_arith, MINUSOP,1, 2, {PP_BINARY, PREC_SUM, 0}},
{"*", do_arith, TIMESOP,1, 2, {PP_BINARY, PREC_PROD, 0}},
-{"/", do_arith, DIVOP, 1, 2, {PP_BINARY2, PREC_PROD, 0}},
+{"/", do_arith, DIVOP, 1, 2, {PP_BINARY, PREC_PROD, 0}},
{"^", do_arith, POWOP, 1, 2, {PP_BINARY2, PREC_POWER, 1}},
{"%%", do_arith, MODOP, 1, 2, {PP_BINARY2, PREC_PERCENT,0}},
{"%/%", do_arith, IDIVOP, 1, 2, {PP_BINARY2, PREC_PERCENT,0}},
(I have removed some blanks so that each line fits in a single line)
Now I get:
R> deparse(parse( text = "a+b-c*d/e" ))
[1] "expression(a + b - c * d / e)"
Does this patch has any negative side effects?
"make check" fails, but AFAIK this is just because of different positions of
line breaks:
[...]
running code in 'reg-tests-2.R' ... OK
comparing 'reg-tests-2.Rout'
to './reg-tests-2.Rout.save' ...3639,3640c3639,3640
< aov(formula = dep.variable ~ f1 * f2 + Error(subject / (f1 +
< f2)), data = sample.df)
---
> aov(formula = dep.variable ~ f1 * f2 + Error(subject/(f1 + f2)),
> data = sample.df)
3693,3694c3693,3694
< aov(formula = dep.variable ~ f1 * f2 + Error(subject / (f2 +
< f1)), data = sample.df)
---
> aov(formula = dep.variable ~ f1 * f2 + Error(subject/(f2 + f1)),
> data = sample.df)
make[3]: *** [reg-tests-2.Rout] Fehler 1
[...]
> Duncan Murdoch
Thank you for all your hints,
Arne
--
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
ahenningsen at agric-econ.uni-kiel.de
http://www.uni-kiel.de/agrarpol/ahenningsen/
More information about the R-devel
mailing list