[R] XML R function description
mtmorgan at fhcrc.org
Thu Dec 13 02:21:10 CET 2007
Nice question! I don't think there is anything exactly like you are
One problem is that in general R function arguments (and return
values) are not typed (!) and of course saying in the docs that a
function takes a particular type of argument is no guarantee that is
the case. A solution is to provide typing (e.g., via the TypeInfo
package in Bioconductor) or to restrict yourself to S4 methods (for
which at least some arguments are typed, though not generally return
values [though I believe they could be specified]).
A very different approach would recognize that R function arguments
are S-expressions of different types (raw, logical, character, int,
double, etc). Marking up R functions in XML then becomes the task of
(a) representing S-expressions or at least their content appropriately
(e.g., an important feature is to allow for NA; see StatDataML), (b)
identifying, perhaps on the fly since new packages are made available
all the time, functions to be exposed (with, e.g., 'get' and the
appropriate 'mode' argument), (c) determining the untyped signature
via 'formals', (d) creating an appropriate map between the (untyped)
signature and the XML representation of (a). This would mark up R
functions in XML without strong typing (i.e., with the level of type
specification currently available to R users!), but still seems,
naively, to be do-able.
I think it's worth asking whether you really want to expose 'all of R'
to C#, because this has significant security consequences (in a server
kind of environment) in addition to implicitly requiring use of the R
language semantics and evaluation model, and without some careful
thought needless movement of data across the R/C# boundary.
Mostly speculative ideas here, so please edit accordingly. Followup
definitely belongs in R-devel, where you might get some much more
Others might suggest less exciting solutions, like (D)COM-based
packages referenced on the 'Other', packages, and FAQs links of the R
"Teodor Krastev" <Krustev at hotmail.com> writes:
> I was wondering if there is a standard for R function description in
> XML (or any plain text) format.
> Rd files are the closest thing I found, but they do not describe the
> argument (or return value) types. The purpose would be to write a
> program to automate the creation of C# wrapper around any R
> function, but without the argument type Rd descriptions are useless.
> Any clues...
> thank you
> Teodor Krastev
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M2 B169
Phone: (206) 667-2793
More information about the R-help