Re: [R] r tidy

From: George Georgalis <george_at_galis.org>
Date: Thu 25 Jan 2007 - 19:35:21 GMT

>On Thu, 25 Jan 2007, George Georgalis wrote:
>
>>Is there an r-tidy program? something that works similar to perl
>>tidy? http://perltidy.sourceforge.net/ which takes program code
>>and reformats white space with standard indentations and spacing?
>>I did find a ruby based rtidy, but that is for html formatting.

On Thu, Jan 25, 2007 at 04:29:06PM +0000, Prof Brian Ripley wrote:
>It is called R.
>
>See the `Writing R Extensions' manual, section 3.1 (the obvious manual,
>surely?).

yes, well actually that was one of the first items I found in my search. but on first pass I was confused, on second pass I understood (sorta incorrectly) that it was about preserving source when writing packages -- then I posted my question.

looking at it again I see the technique could be used to tidy r scripts, but surly the first, the second paragraph or the rest of the section was not written to aid programmers for script tidying? "R treats function code loaded from packages and code entered by users differently."...

Maybe it could go something like this "Your R scripts can be sourced and dumped into a standard tidy format." (insert brief explanation of keep.source, source and dump; which I think I grasp but wouldn't try to explain)

Here's a script to tidy a file as argument $1

#!/bin/sh
R --vanilla <<EOF

     options(keep.source = FALSE)
     source("$1")
     dump(ls(all = TRUE), file = "${1}.tidy.R")
EOF yes, works great, but as one with nearly zero r experience, hoping to apply my other language experience to some R spaghetti, http://cran.r-project.org/doc/manuals/R-exts.html#Tidying-R-code did frighten me off, the first time.

// George

-- 
George Georgalis, systems architect, administrator <IXOYE><

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri Jan 26 06:41:47 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 25 Jan 2007 - 20:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.