From hadley at rice.edu  Thu Mar 29 22:42:25 2012
From: hadley at rice.edu (Hadley Wickham)
Date: Thu, 29 Mar 2012 15:42:25 -0500
Subject: [Rd] CRAN policies
In-Reply-To: <E66794E69CFDE04D9A70842786030B9328EEFC@PA-MBX04.na.tibco.com>
References: <mailman.19.1333015207.14516.r-devel@r-project.org>
	<4F746B54.2050601@mayo.edu>
	<E66794E69CFDE04D9A70842786030B9328EC77@PA-MBX04.na.tibco.com>
	<loom.20120329T190333-975@post.gmane.org>
	<E66794E69CFDE04D9A70842786030B9328EDE3@PA-MBX04.na.tibco.com>
	<4F74B657.5040807@prodsyse.com>
	<E66794E69CFDE04D9A70842786030B9328EEFC@PA-MBX04.na.tibco.com>
Message-ID: <CABdHhvGp4f6KAqa5ba8xB-JH0sh0y87J+xRZeTW9DSwzowpV2g@mail.gmail.com>

> 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/



[Rd] CRAN policies
Hadley Wickham