[R] R multiline expression grief

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Fri Mar 13 15:11:19 CET 2009


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.)

vQ




More information about the R-help mailing list