[Rd] CRAN policies
Hadley Wickham
hadley at rice.edu
Thu Mar 29 22:42:25 CEST 2012
> Most of that stuff is already in codetools, at least when it is checking functions
> with checkUsage(). E.g., arguments of ~ are not checked. The expr argument
> to with() will not be checked if you add skipWith=FALSE to the call to checkUsage.
>
> > library(codetools)
>
> > checkUsage(function(dataFrame) with(dataFrame, {Num/Den ; Resp ~ Pred}))
> <anonymous>: no visible binding for global variable 'Num' (:1)
> <anonymous>: no visible binding for global variable 'Den' (:1)
>
> > checkUsage(function(dataFrame) with(dataFrame, {Num/Den ; Resp ~ Pred}), skipWith=TRUE)
>
> > checkUsage(function(dataFrame) with(DataFrame, {Num/Den ; Resp ~ Pred}), skipWith=TRUE)
> <anonymous>: no visible binding for global variable 'DataFrame'
>
> The only part that I don't see is the mechanism to add code-walker functions to
> the environment in codetools that has the standard list of them for functions with
> nonstandard evaluation:
> > objects(codetools:::collectUsageHandlers, all=TRUE)
> [1] "$" "$<-" ".Internal"
> [4] "::" ":::" "@"
> [7] "@<-" "{" "~"
> [10] "<-" "<<-" "="
> [13] "assign" "binomial" "bquote"
> [16] "data" "detach" "expression"
> [19] "for" "function" "Gamma"
> [22] "gaussian" "if" "library"
> [25] "local" "poisson" "quasi"
> [28] "quasibinomial" "quasipoisson" "quote"
> [31] "Quote" "require" "substitute"
> [34] "with"
It seems like we really need a standard way to add metadata to functions:
attr(with, "special_args") <- "expr"
attr(lm, "special_args") <- c("formula", "weights", "subset")
This would be useful because it could automatically contribute to the
documentation.
Similarly,
attr(my.new.method, "s3method") <- c("my.new", "method")
could be useful.
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
More information about the R-devel
mailing list