[R] Re: none
bates at stat.wisc.edu
Thu May 27 22:05:00 CEST 1999
Jonathan Myles <jonathan.myles at mrc-bsu.cam.ac.uk> writes:
> I am currently preparing an R library to estimate approximate
> posterior distributions for parameters in Generalised Linear Mixed
> Models by Gibbs Sampling which includes a lot of dynamically loaded
> C code. I'm pleased with the way in which it is working and am now
> hammering out some documentation, but closer consideration of some R
> documentation has led me to worry that my code a) may not achieve
> certain standards of R and C programming and b) may not work on all
> systems. (I'm using 0.64.1 on a UNIX system)
> My worries are
> a) That I've used calloc rather than S_alloc throughout.
Using calloc and free in C code loaded by R is fine. We would
recommend that you use the macros Calloc and Free defined in the S.h
include file (the file is named that for historical purposes). Those
macros check if the allocation was successful and provide convenient
coersion of the type of the returned storage.
[discussion of a particular programming technique omitted]
> I *think* I can do it without using this technique, but it will need a lot
> of re-programming. One way round it in S v5 uses the new .Call()
> function---is anything similar on the agenda for future versions of R?
You are in luck. There is a facility in R called .External which is
much like the .Call facility in S-PLUS 5.x. Saikat DebRoy has written
some documentation on that. It would be in the development tree now
except that I was going to a bit of editing on it. I can send you a
preview copy if you like. Please tell me if you can handle texinfo
> On another note, where in the library structure would be a good
> place to put a LaTeX document describing the function and showing
> some examples?
If you haven't already done so, please read the output from the R call
That contains information on how to structure your own libraries.
The preferred way to write the documentation is in a LaTeX-like
formulation called the R documentation (.Rd) format. Those files are put in
the "man" subdirectory of your library. R INSTALL <libname> then
converts those files to html, LaTeX, and ASCII formats when it
installs the library. Furthermore it strips out the examples that you
use in there so you can, for example, do things like
to run the example.
Furthermore, you can use
R CMD check <libname>
to run all the examples in your library - a good way of testing that
changes you have made in your code have not botched things up in
unsuspected ways. In computing this is known as regression testing
but the name "regression" there does not refer to the statistical
concept of regression modeling.
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help