[R] R multiline expression grief

Gabor Grothendieck ggrothendieck at gmail.com
Fri Mar 13 15:21:10 CET 2009


On Fri, Mar 13, 2009 at 10:11 AM, Wacek Kusnierczyk
<Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> wrote:
> Gabor Grothendieck wrote:
>> If all your code has semicolons you could write a program that
>> puts each statement on one line based on the semicolons and
>> then passing it through R will reformat it in a standard way.
>> See Rtidy.bat in the batchfiles distribution for the reformatting part:
>> http://batchfiles.googlecode.com
>>
>
> for the "puts each statement on one line based on the semicolons" part,
> it's enough to pass the program through a simple sed script, *provided*
> that each line not ending in a semicolon is not a complete line:
>
>    sed -n  '/;\s*$/!{H}; /;\s*$/{H;g;s/\n//g;s/;\s*$//;p;s/.//g;h}'
> input > output
>
> (i guess this can be simplified.)
>

One would want to be sure that a comment is not continued onto
a code line.




More information about the R-help mailing list