From ahenningsen at email.uni-kiel.de  Wed Jan 17 23:09:37 2007
From: ahenningsen at email.uni-kiel.de (Arne Henningsen)
Date: Wed, 17 Jan 2007 23:09:37 +0100
Subject: [Rd] Wishlist: Sweave: allow line breaks after forward slashes
	(PR#9444)
In-Reply-To: <45ACBB2B.3000705@stats.uwo.ca>
References: <20070111144243.9B09519BA1@slim.kubism.ku.dk>
	<200701161126.30431.ahenningsen@email.uni-kiel.de>
	<45ACBB2B.3000705@stats.uwo.ca>
Message-ID: <200701172309.37981.ahenningsen@email.uni-kiel.de>

On Tuesday, 16. January 2007 12:46, Duncan Murdoch wrote:
> On 1/16/2007 5:26 AM, Arne Henningsen wrote:
> > [...]
> > 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)"
>
> I don't know, but it has been like that for the complete history of the
> source code in the repository (almost 10 years).  I suppose someone thought
>
>   a + b - c * d /
>   e
>
> would look ugly (even though they were happy to put one of the other
> operators at the end of the line).  

What do the other developeRs and useRs think about this?

> This makes me quite reluctant to 
> change it:  people get upset about changes to the look of their old
> scripts, because they trigger spurious check errors.

Is it possible to add an option to specify whether "/" operators should be 
treated like "+", "-", and "*" operators or not?

Arne

> Duncan Murdoch
>
> >>>> 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/



[Rd] Wishlist: Sweave: allow line breaks after forward slashes (PR#9444)
Arne Henningsen