[R] Clean programming with R

Gabor Grothendieck ggrothendieck at gmail.com
Fri Nov 23 01:03:24 CET 2007


See the codetools package:

> library(codetools)
> checkUsage(power)
<anonymous>: local variable 'p' assigned but may not be used
> findGlobals(power)
[1] "^"      "{"      "<-"     "pp"     "return"


On Nov 22, 2007 5:12 PM, Christophe Genolini <cgenolin at u-paris10.fr> wrote:
> Hi all
>
> Is there any compiler for R ? By compiler, I mean something that check
> the cleanliness of the code : if we declare all the variables we use, if
> we don't use external variable from a function and so on...
> For exemple, something that will ring a bell on the following code
> (saying "line 4 : 'pp' undefine in function 'power' ")
>
> 1. pp <- 3
> 2. power <- function(x){
> 3.    p <- 2
> 4.    return(2^pp)
> 5. }
>
> thanks
>
> Christophe
>
> ______________________________________________
> R-help at r-project.org 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.
>



More information about the R-help mailing list