[R] r tidy
George Georgalis
george at galis.org
Thu Jan 25 20:35:21 CET 2007
>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><
More information about the R-help
mailing list